//////////////////////////////////////////////////////////////////////////////////////////////
        // OnMouseDown Event: we create symbol in the sheet graphics by using SetGraphicsSource(sheet)
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void MouseEvents_OnMouseDown(
            MouseButtonEnum Button,
            ShiftStateEnum ShiftKeys,
            Inventor.Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            if (Button != MouseButtonEnum.kLeftMouseButton)
            {
                return;
            }

            // Define symbol inputs: center, normal, radius

            Point center = ModelPosition;

            UnitVector normal = _Tg.CreateUnitVector(0, 0, 1);

            double radius = _sheet.Width / 30;

            // Add new symbol to the sheet graphics...
            _clientGraphicsMng.SetGraphicsSource(_sheet);

            DrawSymbol(normal, center, radius);

            _clientGraphicsMng.UpdateView();

            _clientGraphicsMng.SetGraphicsSource(
                _interactionManager.InteractionEvents);

            _symbolNode = null;
        }
Beispiel #2
0
        public InventorCamera()
        {
            if (invApp == null)
            {
                try
                {
                    invApp  = (Inventor.Application)Marshal.GetActiveObject("Inventor.Application");
                    started = true;
                }
                catch (Exception ex)
                {
                    started = false;
                    invApp  = null;
                    return;
                }
            }
            if (invApp.Documents.Count == 0)
            {
                opened = false;
                return;
            }

            if (invApp.ActiveDocument.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject || invApp.ActiveDocument.DocumentType == DocumentTypeEnum.kPartDocumentObject || invApp.ActiveDocument.DocumentType == DocumentTypeEnum.kPresentationDocumentObject)
            {
                FindType();
                opened = true;
                oView  = invApp.ActiveView;
                oTG    = invApp.TransientGeometry;
                ReturnHome();
                oCamera = oView.Camera;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Method that reacts to the click event by the user to instantiate the rectangle. This method starts
        /// the ChangeProcessor which encapsulates the drawing of the rectangle into one undo/redo mechanism.
        /// </summary>
        /// <param name="button"></param>
        /// <param name="shiftKeys"></param>
        /// <param name="modelPosition"></param>
        /// <param name="viewPosition"></param>
        /// <param name="view"></param>
        protected void OnMouseClick_LockTheRectangle(MouseButtonEnum button, ShiftStateEnum shiftKeys, Point modelPosition,
                                                     Point2d viewPosition, Inventor.View view)
        {
            try
            {
                if (button == MouseButtonEnum.kLeftMouseButton)
                {
                    _mouseEvents.MouseMoveEnabled = false;

                    if (_mouseEvents.PointInferences.Count > 0)
                    {
                        _inferredFinalPositionPoint = _mouseEvents.PointInferences[1];
                    }

                    _finalPosition = modelPosition;

                    _changeProcessor.Connect();

                    ResetRectangle();

                    _rectangleButton.ButtonPressed = false;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
        //////////////////////////////////////////////////////////////////////////////////////////////
        // OnMouseDown event, creates and start drawing the line graphics
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void MouseEvents_OnMouseDown(
            MouseButtonEnum Button,
            ShiftStateEnum ShiftKeys,
            Inventor.Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            if (Button != MouseButtonEnum.kLeftMouseButton)
            {
                return;
            }

            _lineGraph = _clientGraphicsMng.DrawLine(
                AdnInventorUtilities.ToArray(ModelPosition),
                AdnInventorUtilities.ToArray(ModelPosition),
                null);

            _interactionManager.MouseEvents.MouseMoveEnabled = true;

            _interactionManager.MouseEvents.OnMouseDown -=
                new MouseEventsSink_OnMouseDownEventHandler(MouseEvents_OnMouseDown);

            _interactionManager.MouseEvents.OnMouseMove +=
                new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove);
        }
Beispiel #5
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        //
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void MouseEvents_OnMouseDown(
            MouseButtonEnum Button,
            ShiftStateEnum ShiftKeys,
            Inventor.Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            if (Button != MouseButtonEnum.kLeftMouseButton)
            {
                return;
            }

            if (_lineStripGraph == null)
            {
                double[] front    = AdnInventorUtilities.ToArray(ModelPosition);
                double[] back     = AdnInventorUtilities.ToArray(ModelPosition);
                double[] combined = front.Concat(back).ToArray();

                _rd = new Random();

                _lineStripGraph = _clientGraphicsMng.DrawLineStrip(
                    combined,
                    null);

                _lineStripGraph.ColorBinding = ColorBindingEnum.kPerItemColors;

                int id = _clientGraphicsMng.WorkingGraphics.GetDataSetFreeId();

                _lineStripGraph.ColorSet =
                    _clientGraphicsMng.WorkingGraphics.GraphicsDataSets.CreateColorSet(id);

                _lineStripGraph.ColorSet.Add(
                    _lineStripGraph.ColorSet.Count + 1,
                    (byte)_rd.Next(0, 255),
                    (byte)_rd.Next(0, 255),
                    (byte)_rd.Next(0, 255));

                _lineStripGraph.LineWeight = 5;

                _interactionManager.MouseEvents.MouseMoveEnabled = true;

                _interactionManager.MouseEvents.OnMouseMove +=
                    new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove);
            }
            else
            {
                _lineStripGraph.CoordinateSet.Add(
                    _lineStripGraph.CoordinateSet.Count + 1,
                    ModelPosition);

                _lineStripGraph.ColorSet.Add(
                    _lineStripGraph.ColorSet.Count + 1,
                    (byte)_rd.Next(0, 255),
                    (byte)_rd.Next(0, 255),
                    (byte)_rd.Next(0, 255));
            }
        }
Beispiel #6
0
        private Vector3 GetViewVector(View activeView, ViewOrientationTypeEnum orientation)
        {
            var tempCam = activeView.Camera;

            tempCam.ViewOrientationType = orientation;
            tempCam.ApplyWithoutTransition();
            tempCam = activeView.Camera;
            return(InvToNumericsVec3(tempCam.Target.VectorTo(tempCam.Eye)));
        }
        //////////////////////////////////////////////////////////////////////////////////////////////
        // OnMouseMove events we update end point of the graphic line with current mouse position
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void MouseEvents_OnMouseMove(
            MouseButtonEnum Button,
            ShiftStateEnum ShiftKeys,
            Inventor.Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            _lineGraph.CoordinateSet[2] = ModelPosition;

            _clientGraphicsMng.UpdateView();
        }
Beispiel #8
0
        private void UserInputEvents_OnSelect(ObjectsEnumerator JustSelectedEntities,
                                              ref ObjectCollection MoreSelectedEntities, SelectionDeviceEnum SelectionDevice, Point ModelPosition,
                                              Point2d ViewPosition, Inventor.View View)
        {
            if (JustSelectedEntities.Count > 0)
            {
                var selectedEntity = JustSelectedEntities[1];
                selectedEntity = SelectionInfoSelector.GetSelectionInfo(selectedEntity);

                selectionPropertyGrid.SelectedObject = selectedEntity;
            }
        }
Beispiel #9
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // OnMouseMove event we update the position of our dimension lines and text
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void MouseEvents_OnMouseMove(
            MouseButtonEnum Button,
            ShiftStateEnum ShiftKeys,
            Inventor.Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            Vector normal = View.Camera.Eye.VectorTo(View.Camera.Target);

            UpdateDimension(_dimData, ModelPosition, normal);

            _clientGraphicsMng.UpdateView();
        }
Beispiel #10
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // OnMouseMove event we update the 3rd vertex of our triangle graphics with current position
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void MouseEvents_OnMouseMove(
            MouseButtonEnum Button,
            ShiftStateEnum ShiftKeys,
            Inventor.Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            //Retrieve coordinates and update the 3rd vextex of our graphics triangle
            _triangleGraph.CoordinateSet[3] = ModelPosition;

            //Update active view to see result
            _interactionEvents.InteractionGraphics.UpdateOverlayGraphics(
                AdnInventorUtilities.InvApplication.ActiveView);
        }
Beispiel #11
0
        /// <summary>
        /// This method reacts to the Mouse Move event and calls a method to reposition the points that make
        /// up the rectangle and also subscribes to the mouse click event for when the rectangle is to be
        /// instantiated by the user.
        /// </summary>
        /// <param name="button"></param>
        /// <param name="shiftKeys"></param>
        /// <param name="modelPosition"></param>
        /// <param name="viewPosition"></param>
        /// <param name="view"></param>
        protected void OnMouseMove_DragCornerOfRectangle(MouseButtonEnum button, ShiftStateEnum shiftKeys, Point modelPosition,
                                                         Point2d viewPosition, Inventor.View view)
        {
            AdjustRectanglePosition(modelPosition);


            if (_onMouseClick_Delegate == null)
            {
                _onMouseClick_Delegate     = new MouseEventsSink_OnMouseClickEventHandler(OnMouseClick_LockTheRectangle);
                _mouseEvents.OnMouseClick += _onMouseClick_Delegate;

                _userInputEvents_OnContextMenuDelegate += new UserInputEventsSink_OnContextMenuEventHandler(UserInputEvents_OnContextMenu);
                _userInputEvents.OnContextMenu         += _userInputEvents_OnContextMenuDelegate;
            }
        }
Beispiel #12
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        //
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void MouseEvents_OnMouseMove(
            MouseButtonEnum Button,
            ShiftStateEnum ShiftKeys,
            Inventor.Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            Matrix transfo = _compGraph.Parent.Transformation;

            Vector Tx = AdnInventorUtilities.InvApplication.TransientGeometry.CreateVector(
                ModelPosition.X, ModelPosition.Y, ModelPosition.Z);

            transfo.SetTranslation(Tx, false);

            _compGraph.Parent.Transformation = transfo;

            _clientGraphicsMng.UpdateView();
        }
Beispiel #13
0
 private void ApplicationEvents_OnCloseView(Inventor.View ViewObject, EventTimingEnum BeforeOrAfter, NameValueMap Context,
                                            out HandlingCodeEnum HandlingCode)
 {
     if (BeforeOrAfter == EventTimingEnum.kBefore)
     {
         var doc = ViewObject.Document;
         //Sometimes user may have opened multiple windows for one document.
         if (doc.Views.Count == 1)
         {
             _hwndDic.Remove(doc);
             if (doc == _inventorApplication.ActiveDocument)
             {
                 _myVaultBrowser.Clear();
             }
         }
     }
     HandlingCode = HandlingCodeEnum.kEventNotHandled;
 }
Beispiel #14
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        //
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void MouseEvents_OnMouseDown(
            MouseButtonEnum Button,
            ShiftStateEnum ShiftKeys,
            Inventor.Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            if (Button != MouseButtonEnum.kLeftMouseButton)
            {
                return;
            }

            InsertAsSurfaceGraphics(_compGraph.Parent.Transformation);

            _clientGraphicsMng.SetGraphicsSource(
                _interactionManager.InteractionEvents);

            ComponentDefinition compDef =
                AdnInventorUtilities.GetCompDefinition(_componentDocument);

            _compGraph = _clientGraphicsMng.DrawComponent(compDef);
        }
Beispiel #15
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // OnMouseDown event we create the client feature that holds the dimension graphics
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void MouseEvents_OnMouseDown(
            MouseButtonEnum Button,
            ShiftStateEnum ShiftKeys,
            Inventor.Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            if (Button != MouseButtonEnum.kLeftMouseButton)
            {
                return;
            }

            Vector normal = View.Camera.Eye.VectorTo(View.Camera.Target);

            CreateClientFeature(
                _dimData.Point1,
                _dimData.Point2,
                ModelPosition,
                normal);

            _interactionManager.Terminate();
        }
Beispiel #16
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        //
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void MouseEvents_OnMouseMove(
            MouseButtonEnum Button,
            ShiftStateEnum ShiftKeys,
            Inventor.Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            Point point = AdnInventorUtilities.ProjectOnPlane(ModelPosition, _plane);

            double radius = _center.DistanceTo(
                AdnInventorUtilities.ProjectOnPlane(
                    ModelPosition,
                    _plane));

            Circle circle = AdnInventorUtilities.InvApplication.TransientGeometry.CreateCircle(
                _center,
                _plane.Normal,
                radius);

            _curveGraph.Curve = circle;

            _clientGraphicsMng.UpdateView();
        }
        //////////////////////////////////////////////////////////////////////////////////////////////
        // OnMouseMove Event is used to transform  current GraphicsNode moved by the user
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void MouseEvents_OnMouseMove(
            MouseButtonEnum Button,
            ShiftStateEnum ShiftKeys,
            Inventor.Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            if (_symbolNode == null)
            {
                // Define symbol inputs: center, normal, radius
                Point center = _Tg.CreatePoint(0, 0, 0);

                UnitVector normal = _Tg.CreateUnitVector(0, 0, 1);

                double radius = _sheet.Width / 30;

                _symbolNode = DrawSymbol(normal, center, radius);
            }

            SetNodePosition(_symbolNode, ModelPosition);

            _clientGraphicsMng.UpdateView();
        }
Beispiel #18
0
        /////////////////////////////////////////////////////////////
        // use: OnUnselect ThreadFeature Handler.
        //
        /////////////////////////////////////////////////////////////
        void SelectEvents_OnUnSelect(
            ObjectsEnumerator UnSelectedEntities,
            SelectionDeviceEnum SelectionDevice,
            Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            foreach (System.Object obj in UnSelectedEntities)
            {
                foreach (ListViewItem item in lvFeatures.Items)
                {
                    if (item.Tag == obj)
                    {
                        item.Remove();
                        break;
                    }
                }
            }

            if (_InteractionManager.SelectedEntities.Count == 0)
            {
                bOk.Enabled = false;
            }
        }
        public override void OnPreSelect(object preSelectEntity, out bool doHighlight, ObjectCollection morePreSelectEntities, SelectionDeviceEnum selectionDevice, Point modelPosition, Point2d viewPosition, Inventor.View view)
        {
            doHighlight = false;

            if (preSelectEntity is Face)
            {
                doHighlight = true;
            }
        }
Beispiel #20
0
        /////////////////////////////////////////////////////////////
        // Use: OnSelect ThreadFeature Handler.
        //
        /////////////////////////////////////////////////////////////
        void SelectEvents_OnSelect(
            ObjectsEnumerator JustSelectedEntities,
            SelectionDeviceEnum SelectionDevice,
            Point ModelPosition,
            Point2d ViewPosition,
            Inventor.View View)
        {
            foreach (System.Object obj in JustSelectedEntities)
            {
                PartFeature feature = obj as PartFeature;

                ThreadFeature thread = obj as ThreadFeature;

                ThreadInfo threadInfo = thread.ThreadInfo;

                Face threadedFace = thread.ThreadedFace[1];


                if (feature.Suppressed)
                {
                    continue;
                }

                if (thread.ThreadInfoType == ThreadTypeEnum.kTaperedThread &&
                    threadedFace.SurfaceType != SurfaceTypeEnum.kConeSurface)
                {
                    DialogResult res = MessageBox.Show(
                        "Threaded face surface type is not cone surface but it is applied" +
                        System.Environment.NewLine +
                        "with tapered thread. ThreadModeler cannot modelize this thread.",
                        "Invalid Surface Type",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                    continue;
                }

                string iMateName = string.Empty;

                if (Toolkit.HasiMate(threadedFace,
                                     out iMateName))
                {
                    DialogResult res = MessageBox.Show(
                        "Threaded face or one of its edge has" +
                        " iMate associated to it." +
                        System.Environment.NewLine +
                        "Please delete iMate " + iMateName +
                        " before modelizing this thread.",
                        "Invalid iMate",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);

                    continue;
                }

                double pitch = ThreadWorker.GetThreadPitch(threadInfo);

                string pitchStr =
                    ThreadWorker.GetThreadPitchStr(threadInfo,
                                                   (Document)_Document);

                string minStr =
                    _Document.UnitsOfMeasure.GetStringFromValue(
                        ThreadWorker.ThresholdPitchCm,
                        UnitsTypeEnum.kDefaultDisplayLengthUnits);

                if (pitch < ThreadWorker.ThresholdPitchCm)
                {
                    DialogResult res = MessageBox.Show(
                        "Selected thread pitch " +
                        "is too small (" + pitchStr + ")." +
                        System.Environment.NewLine +
                        "The minimum thread pitch that can " +
                        "be modelized is " + minStr + " .",
                        "Invalid Thread Pitch",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);

                    continue;
                }

                ListViewItem item =
                    lvFeatures.Items.Add(feature.Name);

                item.Tag = feature;

                item.SubItems.Add(pitchStr);

                item.SubItems.Add(ThreadWorker.GetThreadTypeStr(
                                      feature));

                item.SubItems.Add(
                    ThreadWorker.GetThreadedFaceTypeStr(
                        threadedFace));
            }

            _selecSetPopulated = (lvFeatures.Items.Count != 0);

            bOk.Enabled = ValidateOkButton();
        }
Beispiel #21
0
 private void mSelectEvents_OnSelect(Inventor.ObjectsEnumerator JustSelectedEntities, Inventor.SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
 {
     if (JustSelectedEntities.Count != 0)
     {
         object selectedObj = JustSelectedEntities[1];
         System.Windows.Forms.MessageBox.Show((string)("Selected Entity: " + Information.TypeName(selectedObj)), "Simple Interaction");
     }
 }
Beispiel #22
0
        void SelectEvents_OnSelect(
            Inventor.ObjectsEnumerator JustSelectedEntities,
            Inventor.SelectionDeviceEnum SelectionDevice,
            Inventor.Point ModelPosition,
            Inventor.Point2d ViewPosition,
            Inventor.View View)
        {
            if (_state == CommandState.Idle)
            {
                return;
            }

            if (JustSelectedEntities.Count != 1)
            {
                return;
            }

            if (!(JustSelectedEntities[1] is ComponentOccurrence))
            {
                return;
            }

            ComponentOccurrence selectedOccurrence = JustSelectedEntities[1] as ComponentOccurrence;

            switch (_state)
            {
            case CommandState.SourceComponentSelection:

                if (_targetComponent != null)
                {
                    if (selectedOccurrence.Definition == _targetComponent.Definition)
                    {
                        System.Windows.Forms.MessageBox.Show("Source and Target components cannot be the same, or refer to the same document...",
                                                             "Error selecting component",
                                                             System.Windows.Forms.MessageBoxButtons.OK,
                                                             System.Windows.Forms.MessageBoxIcon.Exclamation);

                        break;
                    }
                }

                _state = CommandState.Idle;

                _sourceComponent = selectedOccurrence;

                SourceComponentSelected(this, new EventArgs());

                break;

            case CommandState.TargetComponentSelection:

                if (_sourceComponent != null)
                {
                    if (selectedOccurrence.Definition == _sourceComponent.Definition)
                    {
                        System.Windows.Forms.MessageBox.Show("Source and Target components cannot be the same, or refer to the same document...",
                                                             "Error selecting component",
                                                             System.Windows.Forms.MessageBoxButtons.OK,
                                                             System.Windows.Forms.MessageBoxIcon.Exclamation);

                        break;
                    }
                }

                _state = CommandState.Idle;

                _targetComponent = selectedOccurrence;

                TargetComponentSelected(this, new EventArgs());

                break;

            default:
                _state = CommandState.Idle;
                break;
            }
        }
Beispiel #23
0
 private void select(ObjectsEnumerator JustSelectedEntities, SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View)
 {
 }
Beispiel #24
0
 private void OnPreSelect(ref object PreSelectEntity, out bool DoHighlight, ref Inventor.ObjectCollection MorePreSelectEntities, Inventor.SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
 {
     if (PreSelectEntity is SurfaceGraphicsFace)
     {
         DoHighlight = true;
     }
     else
     {
         DoHighlight = false;
     }
 }
Beispiel #25
0
        public override void OnSelect(ObjectsEnumerator justSelectedEntities, SelectionDeviceEnum selectionDevice, Point modelPosition, Point2d viewPosition, Inventor.View view)
        {
            int nombSelectedEntities = justSelectedEntities.Count;

            if (nombSelectedEntities > 0)
            {
                object selectedEntity = justSelectedEntities[1];

                //if cavity face is selected
                if ((m_insertXportForm.checkfirstFace.Checked) && (selectedEntity != m_secondFace))
                {
                    m_firstFace = (Face)selectedEntity;

                    m_insertXportForm.checkfirstFace.Checked = false;

                    if (m_secondFace == null)
                    {
                        m_insertXportForm.checksecondFace.Checked = true;

                        EnableInteraction();
                    }
                    else
                    {
                        DisableInteraction();

                        UpdateCommandStatus();
                    }
                }

                if ((m_insertXportForm.checksecondFace.Checked) && (selectedEntity != m_firstFace))
                {
                    m_secondFace = (Face)selectedEntity;

                    m_insertXportForm.checksecondFace.Checked = false;

                    if (m_firstFace == null)
                    {
                        m_insertXportForm.checkfirstFace.Checked = true;

                        EnableInteraction();
                    }
                    else
                    {
                        DisableInteraction();

                        UpdateCommandStatus();
                    }
                }
            }
        }
 public override void OnSelect(ObjectsEnumerator justSelectedEntities, SelectionDeviceEnum selectionDevice, Point modelPosition, Point2d viewPosition, Inventor.View view)
 {
     if (m_boltHoleForm.checkBoxFace.Checked == true)
     {
         if (m_withThisFace == null)
         {
             m_withThisFace = justSelectedEntities[1];
             this.HightghtSelectFace(m_withThisFace);
         }
         else
         {
             this.ClearHighlight();
             m_withThisFace = justSelectedEntities[1];
             this.HightghtSelectFace(m_withThisFace);
         }
         m_boltHoleForm.checkBoxFace.Checked = false;
     }
 }
Beispiel #27
0
 public override void OnMouseUp(MouseButtonEnum button, ShiftStateEnum shiftKeys, Point modelPosition, Point2d viewPosition, Inventor.View view)
 {
     AddInformation();
 }
Beispiel #28
0
        public override void OnPreSelect(object preSelectEntity, out bool doHighlight, ObjectCollection morePreSelectEntities, SelectionDeviceEnum selectionDevice, Point modelPosition, Point2d viewPosition, Inventor.View view)
        {
            doHighlight = false;

            if (preSelectEntity is Face)
            {
                Face preSelectFace = (Face)preSelectEntity;

                if (preSelectFace.SurfaceType == SurfaceTypeEnum.kCylinderSurface)
                {
                    PartDocument oPartDoc = (PartDocument)m_inventorApplication.ActiveDocument;

                    iFeatures oiFeatures = oPartDoc.ComponentDefinition.Features.iFeatures;

                    foreach (iFeature oiFeature in oiFeatures)
                    {
                        Faces oFaces;
                        oFaces = oiFeature.Faces;
                        foreach (Face oFace in oFaces)
                        {
                            if (oFace == preSelectFace)
                            {
                                doHighlight = true;
                                break;
                            }
                        }
                    }
                }
            }
        }
Beispiel #29
0
        public override void OnSelect(ObjectsEnumerator justSelectedEntities, SelectionDeviceEnum selectionDevice, Point modelPosition, Point2d viewPosition, Inventor.View view)
        {
            int nomb = justSelectedEntities.Count;

            if (nomb > 0)
            {
                object selectedEntity = justSelectedEntities[1];

                if (m_editNetForm.checkBoxChoose.Checked)
                {
                    m_selectFace = (Face)selectedEntity;

                    m_editNetForm.checkBoxChoose.Checked = false;
                }

                this.GetSelectiFeature(m_selectFace, ref m_selectiFeature);

                m_selectEvents.AddToSelectedEntities(m_selectiFeature);

                DisableInteraction();

                UpdateCommandStatus();
            }
        }
Beispiel #30
0
        /// <summary>
        /// When the user clicks on a point in the model, this method runs and creates an interaction graphics rectangle.
        /// It also subscribes to the Mouse Move event to allow for the size of the rectangle to be driven by the location
        /// of the mouse on the sketch. Ultimately, this method waits for the next click event, in which case it calls a
        /// new method to actually create the sketched rectangle.  It has separate paths to react to whether it's a part
        /// sketch or a drawing sketch.
        /// </summary>
        /// <param name="button"></param>
        /// <param name="shiftKeys"></param>
        /// <param name="modelPosition"></param>
        /// <param name="viewPosition"></param>
        /// <param name="view"></param>
        protected void OnMouseClick_CreateRectangle(MouseButtonEnum button, ShiftStateEnum shiftKeys, Point modelPosition,
                                                    Point2d viewPosition, Inventor.View view)
        {
            try
            {
                if (button == MouseButtonEnum.kLeftMouseButton)
                {
                    _onMouseMove_Delegate                  = new MouseEventsSink_OnMouseMoveEventHandler(OnMouseMove_DragCornerOfRectangle);
                    _mouseEvents.OnMouseClick             -= _onMouseClick_Delegate;
                    _onMouseClick_Delegate                 = null;
                    _userInputEvents.OnContextMenu        -= _userInputEvents_OnContextMenuDelegate;
                    _userInputEvents_OnContextMenuDelegate = null;

                    if (_inventorApplication.ActiveEditObject is PlanarSketch)
                    {
                        _planarSketch = (PlanarSketch)_inventorApplication.ActiveEditObject;

                        if (_mouseEvents.PointInferences.Count > 0)
                        {
                            _inferredOriginPoint = _mouseEvents.PointInferences[1];

                            switch (_inferredOriginPoint.InferenceType)
                            {
                            case PointInferenceEnum.kPtAtIntersection:
                                _firstSelectedSketchEntity            = (SketchEntity)_inferredOriginPoint.Entity[1];
                                _firstInferredIntersectedSketchEntity = (SketchEntity)_inferredOriginPoint.Entity[2];
                                break;

                            case PointInferenceEnum.kPtOnCurve:
                                _firstSelectedSketchEntity = (SketchEntity)_inferredOriginPoint.Entity[1];
                                break;

                            case PointInferenceEnum.kPtOnPt:
                                _firstSelectedSketchEntity  = (SketchPoint)_inferredOriginPoint.Entity[1];
                                _pickedSketchPoint          = (SketchPoint)_firstSelectedSketchEntity;
                                _rectangleOriginSketchPoint = _pickedSketchPoint;
                                break;

                            case PointInferenceEnum.kPtAtMidPoint:
                                _firstSelectedSketchEntity = (SketchLine)_inferredOriginPoint.Entity[1];
                                break;
                            }
                        }

                        _pickedPoint2d = _planarSketch.ModelToSketchSpace(modelPosition);

                        DrawInteractionRectangle();

                        _mouseEvents.OnMouseMove     += _onMouseMove_Delegate;
                        _mouseEvents.MouseMoveEnabled = true;
                    }
                    else if (_inventorApplication.ActiveEditObject is DrawingSketch)
                    {
                        _drawingSketch = (DrawingSketch)_inventorApplication.ActiveEditObject;

                        if (_mouseEvents.PointInferences.Count > 0)
                        {
                            _inferredOriginPoint = _mouseEvents.PointInferences[1];

                            switch (_inferredOriginPoint.InferenceType)
                            {
                            case PointInferenceEnum.kPtAtIntersection:
                                _firstSelectedSketchEntity            = (SketchEntity)_inferredOriginPoint.Entity[1];
                                _firstInferredIntersectedSketchEntity = (SketchEntity)_inferredOriginPoint.Entity[2];
                                break;

                            case PointInferenceEnum.kPtOnCurve:
                                _firstSelectedSketchEntity = (SketchEntity)_inferredOriginPoint.Entity[1];
                                break;

                            case PointInferenceEnum.kPtOnPt:
                                _firstSelectedSketchEntity  = (SketchPoint)_inferredOriginPoint.Entity[1];
                                _pickedSketchPoint          = (SketchPoint)_firstSelectedSketchEntity;
                                _rectangleOriginSketchPoint = _pickedSketchPoint;
                                break;

                            case PointInferenceEnum.kPtAtMidPoint:
                                _firstSelectedSketchEntity = (SketchLine)_inferredOriginPoint.Entity[1];
                                break;
                            }
                        }
                        PointToPoint2d(modelPosition, out _pickedPoint2d);

                        DrawInteractionRectangle();

                        _mouseEvents.OnMouseMove     += _onMouseMove_Delegate;
                        _mouseEvents.MouseMoveEnabled = true;
                    }
                    else
                    {
                        MessageBox.Show("You must be editing a sketch in order to use this tool.");
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }