コード例 #1
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // First selection will be a planar face or workplane used as slicing plane
        // Subsequent selections will be graphic node, so we switch nodes visibility
        //   to reverse the normal of slicing plane
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void SelectEvents_OnSelect(
            ObjectsEnumerator JustSelectedEntities,
            SelectionDeviceEnum SelectionDevice,
            Point ModelPosition,
            Point2d ViewPosition,
            View View)
        {
            if (JustSelectedEntities[1] is GraphicsNode)
            {
                SwitchNodesVisibility();
                return;
            }

            _interactionManager.ClearSelectionFilters();

            SetModelVisibility(false);

            switch (AdnInventorUtilities.InvApplication.ActiveDocument.DocumentType)
            {
            case DocumentTypeEnum.kAssemblyDocumentObject:

                foreach (ComponentOccurrence occurrence in _compDef.Occurrences)
                {
                    occurrence.Visible = false;
                }
                break;

            case DocumentTypeEnum.kPartDocumentObject:

                foreach (KeyValuePair <SurfaceBody, SurfaceBody> pair in _surfaceBodies)
                {
                    pair.Key.Visible = false;
                }
                break;

            default:
                return;
            }

            Plane plane1 = AdnInventorUtilities.GetPlane(JustSelectedEntities[1]);

            _nodes1 = CreateSlicedNodes(plane1, false);

            Vector normal2 = plane1.Normal.AsVector();

            normal2.ScaleBy(-1.0);

            Plane plane2 =
                AdnInventorUtilities.InvApplication.TransientGeometry.CreatePlane(
                    plane1.RootPoint,
                    normal2);

            _nodes2 = CreateSlicedNodes(plane2, true);

            _clientGraphicsMng.UpdateView();
        }
コード例 #2
0
        private void UserInputEvents_OnLinearMarkingMenu(ObjectsEnumerator SelectedEntities, SelectionDeviceEnum SelectionDevice,
                                                         CommandControls LinearMenu, NameValueMap AdditionalInfo)
        {
            var control = _inventorApplication.CommandManager.ControlDefinitions["VaultFindInBrowser"];

            if (SelectedEntities.Count == 1 && SelectedEntities[1] is ComponentOccurrence)
            {
                LinearMenu.AddButton((ButtonDefinition)control);
            }
        }
コード例 #3
0
 /// <summary>
 /// Enables the "Add Selection" button when an object in Inventor is selected.
 /// </summary>
 /// <param name="JustSelectedEntities"></param>
 /// <param name="SelectionDevice"></param>
 /// <param name="ModelPosition"></param>
 /// <param name="ViewPosition"></param>
 /// <param name="View"></param>
 private void selectEvents_OnSelect(ObjectsEnumerator JustSelectedEntities, SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View)
 {
     if (!addSelectionButton.Enabled)
     {
         addSelectionButton.Invoke(new Action(() =>
         {
             addSelectionButton.Enabled = true;
         }));
     }
 }
コード例 #4
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;
            }
        }
コード例 #5
0
        /// <summary>
        /// select a SketchLine and SketchCircle and get their  intersect points
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button2_Click(object sender, EventArgs e)
        {
            if (((mApp.ActiveDocument != null)))
            {
                if ((mApp.ActiveDocument.DocumentType == DocumentTypeEnum.kPartDocumentObject))
                {
                    PartDocument oDoc = mApp.ActiveDocument as PartDocument;

                    if ((oDoc.SelectSet.Count == 2))
                    {
                        if (((oDoc.SelectSet[1]) is SketchLine & (oDoc.SelectSet[2]) is SketchCircle))
                        {
                            SketchLine   oSketchLine   = oDoc.SelectSet[1] as SketchLine;
                            SketchCircle oSketchCircle = oDoc.SelectSet[2] as SketchCircle;

                            Line2d   oLine2d   = mApp.TransientGeometry.CreateLine2d(oSketchLine.Geometry.StartPoint, oSketchLine.Geometry.Direction);
                            Circle2d oCircle2d = oSketchCircle.Geometry;

                            ObjectsEnumerator objectsEnum = oLine2d.IntersectWithCurve(oCircle2d, 0.0001);

                            if ((objectsEnum == null))
                            {
                                System.Windows.Forms.MessageBox.Show("No intersection between extended Line and Circle", "BRep Sample");
                                return;
                            }

                            string strResult = "Intersection point(s): \n";

                            int i = 0;
                            for (i = 1; i <= objectsEnum.Count; i++)
                            {
                                Point2d oPoint = objectsEnum[i] as Point2d;
                                strResult += "[" + oPoint.X.ToString("F2") + ", " + oPoint.Y.ToString("F2") + "]" + "\n";
                            }

                            System.Windows.Forms.MessageBox.Show(strResult, "BRep Sample");
                            return;
                        }
                        else
                        {
                            System.Windows.Forms.MessageBox.Show("Entity 1 must be a SketchLine, Entity 2 must be a SketchCircle", "BRep Sample");
                            return;
                        }
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show("Incorrect selection of sketch entities", "BRep Sample");
                        return;
                    }
                }
            }
        }
コード例 #6
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();
                    }
                }
            }
        }
コード例 #7
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_alignCmdDlg.checkBoxCavity.Checked) && (selectedEntity != m_withThisFace))
                {
                    m_thisFace = (Face)selectedEntity;

                    m_alignCmdDlg.checkBoxCavity.Checked = false;

                    if (m_withThisFace == null)
                    {
                        m_alignCmdDlg.checkBoxWithThisCavity.Checked = true;

                        EnableInteraction();
                    }
                    else
                    {
                        DisableInteraction();

                        UpdateCommandStatus();
                    }
                }

                if ((m_alignCmdDlg.checkBoxWithThisCavity.Checked) && (selectedEntity != m_thisFace))
                {
                    m_withThisFace = (Face)selectedEntity;

                    m_alignCmdDlg.checkBoxWithThisCavity.Checked = false;

                    if (m_thisFace == null)
                    {
                        m_alignCmdDlg.checkBoxCavity.Checked = true;

                        EnableInteraction();
                    }
                    else
                    {
                        DisableInteraction();

                        UpdateCommandStatus();
                    }
                }
            }
        }
コード例 #8
0
        /////////////////////////////////////////////////////////////
        // Use: OnSelect Handler.
        //
        /////////////////////////////////////////////////////////////
        private void SelectEvents_OnSelect(
            ObjectsEnumerator JustSelectedEntities,
            SelectionDeviceEnum SelectionDevice,
            Point ModelPosition,
            Point2d ViewPosition,
            View View)
        {
            if (JustSelectedEntities.Count != 0)
            {
                System.Object selectedObj = JustSelectedEntities[1];

                _SelectedEntities.Add(selectedObj);
            }
        }
コード例 #9
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // SelectEvent lets the user pick up vertex or workpoint
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void SelectEvents_OnSelect(ObjectsEnumerator JustSelectedEntities,
                                   SelectionDeviceEnum SelectionDevice,
                                   Point ModelPosition,
                                   Point2d ViewPosition,
                                   View View)
        {
            switch (_mode)
            {
            case ModeEnum.kPoint1:
            {
                _point1 = ModelPosition;
                _mode   = ModeEnum.kPoint2;
                _interactionManager.InteractionEvents.StatusBarText = "Select dimension second point: ";
                break;
            }

            case ModeEnum.kPoint2:
            {
                _point2 = ModelPosition;

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

                _dimData = DrawDimension(_point1, _point2, ModelPosition, normal);

                _clientGraphicsMng.UpdateView();


                _interactionManager.InteractionEvents.StatusBarText = "Select dimension text position: ";

                _interactionManager.MouseEvents.MouseMoveEnabled = true;

                _interactionManager.SelectEvents.OnSelect -=
                    new SelectEventsSink_OnSelectEventHandler(SelectEvents_OnSelect);

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

                _interactionManager.MouseEvents.OnMouseMove +=
                    new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove);

                _mode = ModeEnum.kDimText;

                break;
            }

            default:
                break;
            }
        }
コード例 #10
0
        private GeometryIntent attach(Point2d ptPoz)
        {
            ObjectsEnumerator obj = sh.FindUsingPoint(ptPoz);

            if (obj.Count != 0)
            {
                if (obj[1] is DrawingCurveSegment)
                {
                    DrawingCurveSegment dcs = obj[1] as DrawingCurveSegment;
                    GeometryIntent      gi  = sh.CreateGeometryIntent(dcs.Parent, ptPoz);
                    return(gi);
                }
            }
            return(null);
        }
コード例 #11
0
 /////////////////////////////////////////////////////////////
 // Use: OnUnSelect Handler.
 //
 /////////////////////////////////////////////////////////////
 void SelectEvents_OnUnSelect(
     ObjectsEnumerator UnSelectedEntities,
     SelectionDeviceEnum SelectionDevice,
     Point ModelPosition,
     Point2d ViewPosition,
     View View)
 {
     foreach (System.Object unselectedObj in
              UnSelectedEntities)
     {
         if (_SelectedEntities.Contains(unselectedObj))
         {
             _SelectedEntities.Remove(unselectedObj);
         }
     }
 }
コード例 #12
0
 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;
     }
 }
コード例 #13
0
 private void OnResetCommandBars(ObjectsEnumerator commandBars, NameValueMap context)
 {
     try
     {
         foreach (CommandBar commandBar in commandBars)
         {
             if (commandBar.InternalName == "PMxPartFeatureCmdBar")
             {
                 _createTopAndLeftViewButton.AddTo(commandBar);
                 _createPartViewsFromAssemblyButton.AddTo(commandBar);
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
コード例 #14
0
        private void OnSelect(ObjectsEnumerator JustSelectedEntities, SelectionDeviceEnum SelectionDevice, Point ModelPosition, Point2d ViewPosition, View View)
        {
            if (JustSelectedEntities.Count == 0)
            {
                return;
            }

            SurfaceGraphicsFace face = JustSelectedEntities[1] as SurfaceGraphicsFace;

            if (null != face)
            {
                mSelectedFace = face;
            }

            if (mRadius < 0.0001)
            {
                CalculateRadius();
            }
            mSelectEvents.ResetSelections();
        }
コード例 #15
0
        private void UserInterfaceEvents_OnResetCommandBars(ObjectsEnumerator commandBars, NameValueMap context)
        {
            try
            {
                CommandBar commandBar;
                for (int commandBarCt = 1; commandBarCt <= commandBars.Count; commandBarCt++)
                {
                    commandBar = (Inventor.CommandBar)commandBars[commandBarCt];
                    if (commandBar.InternalName == commandBarInternalName)
                    {
                        commandBar.Controls.AddButton(dynamoAddinButton.ButtonDefinition, 0);
                        return;
                    }
                }
            }

            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
コード例 #16
0
        private void UserInterfaceEvents_OnResetEnvironments(ObjectsEnumerator environments, NameValueMap context)
        {
            //TODO: Fix this
            try
            {
                Inventor.Environment environment;
                for (int i = 1; i <= environments.Count; i++)
                {
                    environment = (Inventor.Environment)environments[i];
                    if (environment.InternalName == "AMxAssemblyEnvironment")
                    {
                        environment.PanelBar.CommandBarList.Add(inventorApplication.UserInterfaceManager.CommandBars[commandBarInternalName]);
                    }
                }
            }

            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
コード例 #17
0
        private void UserInterfaceEvents_OnResetCommandBars(ObjectsEnumerator commandBars, NameValueMap context)
        {
            try
            {
                CommandBar commandBar;
                for (int commandBarCt = 1; commandBarCt <= commandBars.Count; commandBarCt++)
                {
                    commandBar = (Inventor.CommandBar)commandBars[commandBarCt];
                    if (commandBar.InternalName == "Autodesk:Mugen:AnistropyToolbar")
                    {
                        //add buttons to toolbar
                        commandBar.Controls.AddButton(m_addSlotOptionButton.ButtonDefinition, 0);

                        return;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
コード例 #18
0
        private void UserInterfaceEvents_OnResetCommandBars(ObjectsEnumerator commandBars, NameValueMap context)
        {
            try
            {
                CommandBar commandBar;
                for (int commandBarCt = 1; commandBarCt <= commandBars.Count; commandBarCt++)
                {
                    commandBar = (Inventor.CommandBar)commandBars[commandBarCt];
                    if (commandBar.InternalName == "PMxPartFeatureCmdBar")
                    {
                        //add button back to the part features toolbar
                        commandBar.Controls.AddButton(m_blockFormCmd.ButtonDefinition, 0);

                        return;
                    }
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
            }
        }
コード例 #19
0
        private void UserInterfaceEvents_OnResetCommandBars(ObjectsEnumerator commandBars, NameValueMap context)
        {
            try
            {
                CommandBar commandBar;
                for (int commandBarCt = 1; commandBarCt <= commandBars.Count; commandBarCt++)
                {
                    commandBar = (Inventor.CommandBar)commandBars[commandBarCt];
                    if (commandBar.InternalName == "MasterModel:StandardAddInServer:BenjaminBUTTONToolbar")
                    {
                        //add buttons to toolbar
                        commandBar.Controls.AddButton(ButtON.ButtonDefinition, 0);

                        return;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
コード例 #20
0
        private void UserInterfaceEvents_OnResetEnvironments(ObjectsEnumerator environments, NameValueMap context)
        {
            try
            {
                Inventor.Environment environment;
                for (int environmentCt = 1; environmentCt <= environments.Count; environmentCt++)
                {
                    environment = (Inventor.Environment)environments[environmentCt];
                    if (environment.InternalName == "PMxPartEnvironment")
                    {
                        //make this command bar accessible in the panel menu for the 2d sketch environment.
                        environment.PanelBar.CommandBarList.Add(m_inventorApplication.UserInterfaceManager.CommandBars["MasterModel:StandardAddInServer:BenjaminBUTTONToolbar"]);

                        return;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
コード例 #21
0
        static void SelectEvents_OnSelect(
            ObjectsEnumerator JustSelectedEntities,
            SelectionDeviceEnum SelectionDevice,
            Point ModelPosition,
            Point2d ViewPosition,
            View View)
        {
            VertexSelectEffect effect = new VertexSelectEffect(
                _clientGraphicsMng,
                ModelPosition,
                0.01,
                0.8);

            RenderStyles styles =
                AdnInventorUtilities.GetProperty(
                    AdnInventorUtilities.InventorApplication.ActiveDocument,
                    "RenderStyles") as RenderStyles;

            effect.GraphicsNode.RenderStyle = styles["Glass (Limo Tint)"];

            _clientGraphicsMng.DrawDynamicGraphics(effect);
        }
コード例 #22
0
        static void SelectEvents_OnSelect(
            ObjectsEnumerator JustSelectedEntities, 
            SelectionDeviceEnum SelectionDevice, 
            Point ModelPosition, 
            Point2d ViewPosition, 
            View View)
        {
            VertexSelectEffect effect = new VertexSelectEffect(
                _clientGraphicsMng,
                ModelPosition, 
                0.01, 
                0.8);

            RenderStyles styles =
                AdnInventorUtilities.GetProperty(
                    AdnInventorUtilities.InventorApplication.ActiveDocument, 
                    "RenderStyles") as RenderStyles;

            effect.GraphicsNode.RenderStyle = styles["Glass (Limo Tint)"];

            _clientGraphicsMng.DrawDynamicGraphics(effect);
        }
コード例 #23
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;
            }
        }
コード例 #24
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_editCavityLibrary.checkBoxFace.Checked)
                {
                    m_withThisFace = (Face)selectedEntity;

                    m_editCavityLibrary.checkBoxFace.Checked = false;

                    m_mouseFlag = true;
                }
            }

            m_selectEvents.AddToSelectedEntities(m_withThisFace);

            DisableInteraction();

            UpdateCommandStatus();
        }
コード例 #25
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();
            }
        }
コード例 #26
0
 private void selectEvts(ObjectsEnumerator JustSelectedEntities, SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View)
 {
     selEvts.AddToSelectedEntities(JustSelectedEntities[1]);
 }
コード例 #27
0
 public void GetDegreesOfFreedom(out int translationDegreesCount, out ObjectsEnumerator translationDegreesVectors, out int rotationDegreesCount, out ObjectsEnumerator rotationDegreesVectors, out Point dOFCenter)
 {
     InternalGetDegreesOfFreedom(out  translationDegreesCount, out  translationDegreesVectors, out  rotationDegreesCount, out  rotationDegreesVectors, out  dOFCenter);
 }
コード例 #28
0
ファイル: CircleJig.cs プロジェクト: derzzle/INV2016_TRN
        //////////////////////////////////////////////////////////////////////////////////////////////
        // 
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void SelectEvents_OnSelect(
            ObjectsEnumerator JustSelectedEntities, 
            SelectionDeviceEnum SelectionDevice, 
            Point ModelPosition, 
            Point2d ViewPosition, 
            View View)
        {
            switch (_mode)
            {
                case SelectModeEnum.kPlaneSelect:
                    {
                        _plane = AdnInventorUtilities.GetPlane(JustSelectedEntities[1]);

                        _interactionManager.MouseEvents.MouseMoveEnabled = true;

                        _interactionManager.ClearSelectionFilters();

                        _interactionManager.AddSelectionFilter(SelectionFilterEnum.kPartVertexFilter);
                        _interactionManager.AddSelectionFilter(SelectionFilterEnum.kWorkPointFilter);

                        _interactionManager.InteractionEvents.StatusBarText = "Select center: ";

                        _mode = SelectModeEnum.kCenterSelect;

                        break;
                    }
                case SelectModeEnum.kCenterSelect:
                    {
                        _center = AdnInventorUtilities.GetPoint(JustSelectedEntities[1]);

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

                        _curveGraph = _clientGraphicsMng.DrawCurve(circle);

                        _curveGraph.LineWeight = 0.5;

                        _interactionManager.InteractionEvents.StatusBarText = "Select radius: ";

                        _interactionManager.MouseEvents.OnMouseMove +=
                            new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove);

                        _interactionManager.SelectEvents.OnSelect -=
                           new SelectEventsSink_OnSelectEventHandler(SelectEvents_OnSelect);

                        _mode = SelectModeEnum.kRadiusSelect;

                        break;
                    }
                default:
                    break;
            }
        }
コード例 #29
0
 private void select(ObjectsEnumerator JustSelectedEntities, SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View)
 {
 }
コード例 #30
0
 private void InternalGetDegreesOfFreedom(out int translationDegreesCount, out ObjectsEnumerator translationDegreesVectors, out int rotationDegreesCount, out ObjectsEnumerator rotationDegreesVectors, out Point dOFCenter)
 {
     Inventor.Point dOFCenterInv;
     ComponentOccurrenceInstance.GetDegreesOfFreedom(out  translationDegreesCount, out  translationDegreesVectors, out  rotationDegreesCount, out  rotationDegreesVectors, out  dOFCenterInv);
     dOFCenter = dOFCenterInv.ToPoint();
 }
コード例 #31
0
        private void UserInterfaceEvents_OnResetCommandBars(ObjectsEnumerator commandBars, NameValueMap context)
        {
            try
            {
                CommandBar commandBar;
                for (int commandBarCt = 1; commandBarCt <= commandBars.Count; commandBarCt++)
                {
                    commandBar = (Inventor.CommandBar)commandBars[commandBarCt];
                    if (commandBar.InternalName == "Autodesk:SimpleAddIn:SlotToolbar")
                    {
                        //add comboboxes to toolbar
                        commandBar.Controls.AddComboBox(m_slotWidthComboBoxDefinition, 0);
                        commandBar.Controls.AddComboBox(m_slotHeightComboBoxDefinition, 0);

                        //add buttons to toolbar
                        commandBar.Controls.AddButton(m_addSlotOptionButton.ButtonDefinition, 0);
                        commandBar.Controls.AddButton(m_drawSlotButton.ButtonDefinition, 0);
                        commandBar.Controls.AddButton(m_toggleSlotStateButton.ButtonDefinition, 0);

                        return;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
コード例 #32
0
        private void UserInterfaceEvents_OnResetEnvironments(ObjectsEnumerator environments, NameValueMap context)
        {
            try
            {
                Inventor.Environment environment;
                for (int environmentCt = 1; environmentCt <= environments.Count; environmentCt++)
                {
                    environment = (Inventor.Environment)environments[environmentCt];
                    if (environment.InternalName == "PMxPartSketchEnvironment")
                    {
                        //make this command bar accessible in the panel menu for the 2d sketch environment.
                        environment.PanelBar.CommandBarList.Add(m_inventorApplication.UserInterfaceManager.CommandBars["Autodesk:SimpleAddIn:SlotToolbar"]);

                        return;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
コード例 #33
0
        private void UserInterfaceEvents_OnResetCommandBars(ObjectsEnumerator commandBars, NameValueMap context)
        {
            try
            {
                CommandBar commandBar;
                for (int commandBarCt = 1; commandBarCt <= commandBars.Count; commandBarCt++)
                {
                    commandBar = (Inventor.CommandBar)commandBars[commandBarCt];
                    if (commandBar.InternalName == commandBarInternalName)
                    {
                        commandBar.Controls.AddButton(dynamoAddinButton.ButtonDefinition, 0);
                        return;
                    }
                }
            }

            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
コード例 #34
0
        private void UserInterfaceEvents_OnResetEnvironments(ObjectsEnumerator environments, NameValueMap context)
        {
            //TODO: Fix this
            try
            {
                Inventor.Environment environment;
                for (int i = 1; i <= environments.Count; i++)
                {
                    environment = (Inventor.Environment)environments[i];
                    if (environment.InternalName == "AMxAssemblyEnvironment")
                    {
                        environment.PanelBar.CommandBarList.Add(inventorApplication.UserInterfaceManager.CommandBars[commandBarInternalName]);
                    }
                }
            }

            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
コード例 #35
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        // SelectEvent lets the user pick up vertex or workpoint
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void SelectEvents_OnSelect(ObjectsEnumerator JustSelectedEntities,
           SelectionDeviceEnum SelectionDevice,
           Point ModelPosition,
           Point2d ViewPosition,
           View View)
        {
            switch (_mode)
            {
                case ModeEnum.kPoint1:
                    {
                        _point1 = ModelPosition;
                        _mode = ModeEnum.kPoint2;
                        _interactionManager.InteractionEvents.StatusBarText = "Select dimension second point: ";
                        break;
                    }
                case ModeEnum.kPoint2:
                    {
                        _point2 = ModelPosition;

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

                        _dimData = DrawDimension(_point1, _point2, ModelPosition, normal);

                        _clientGraphicsMng.UpdateView();


                        _interactionManager.InteractionEvents.StatusBarText = "Select dimension text position: ";

                        _interactionManager.MouseEvents.MouseMoveEnabled = true;

                        _interactionManager.SelectEvents.OnSelect -=
                            new SelectEventsSink_OnSelectEventHandler(SelectEvents_OnSelect);

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

                        _interactionManager.MouseEvents.OnMouseMove +=
                            new MouseEventsSink_OnMouseMoveEventHandler(MouseEvents_OnMouseMove);

                        _mode = ModeEnum.kDimText;

                        break;
                    }
 
                default:
                    break;
            }
        }
コード例 #36
0
ファイル: frmSelection.cs プロジェクト: guchanghai/Cut
        void select_OnSelect(ObjectsEnumerator JustSelectedEntities, SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Point2d ViewPosition, Inventor.View View)
        {
            //������ѡ�ߵij���
            int i;
            double length = 0.0;
            for (i = 0; i < JustSelectedEntities.Count; i++)
            {
                //��Ϊ�Ѿ�����������Ϊѡ��ߣ����Խ����ص�ͼԪָ��ΪEdge�����ǰ�ȫ��
                Edge edge;
                edge = (Edge)JustSelectedEntities[i];

                //ȷ����ǰ�ߵij���
                double min;
                double max;
                edge.Evaluator.GetParamExtents(out min, out max);

                double singleLength;
                edge.Evaluator.GetLengthAtParam(min, max, out singleLength);

                //���㼯�������бߵij���
                length = length + singleLength;
            }

            //��ʾ�ߵij��Ⱥ�����
            txtLength.Text = string.Format("{0} cm", length);
            txtEdgeCount.Text = string.Format("{0}", JustSelectedEntities.Count);
        }
コード例 #37
0
        /////////////////////////////////////////////////////////////
        // Use: OnSelect Handler.
        //
        /////////////////////////////////////////////////////////////
        private void SelectEvents_OnSelect(
            ObjectsEnumerator JustSelectedEntities,
            SelectionDeviceEnum SelectionDevice,
            Point ModelPosition,
            Point2d ViewPosition,
            View View)
        {
            if (JustSelectedEntities.Count != 0)
            {
                System.Object selectedObj = JustSelectedEntities[1];

                _SelectedEntities.Add(selectedObj);
            }
        }
コード例 #38
0
 /////////////////////////////////////////////////////////////
 // Use: OnUnSelect Handler.
 //
 /////////////////////////////////////////////////////////////
 void SelectEvents_OnUnSelect(
     ObjectsEnumerator UnSelectedEntities,
     SelectionDeviceEnum SelectionDevice,
     Point ModelPosition,
     Point2d ViewPosition,
     View View)
 {
     foreach (System.Object unselectedObj in
         UnSelectedEntities)
     {
         if (_SelectedEntities.Contains(unselectedObj))
         {
             _SelectedEntities.Remove(unselectedObj);
         }
     }
 }
コード例 #39
0
        //------------------------------------------------------------------------------


        //------------------Implementation of Select Events sink method-----------------
        //------------------------------------------------------------------------------
        public void SelectEvents_OnSelect(ObjectsEnumerator justSelectedEntities, SelectionDeviceEnum selectionDevice, Point modelPosition, Point2d viewPosition, View view)
        {
            //not implemented
            m_parentCmd.OnSelect(justSelectedEntities, selectionDevice, modelPosition, viewPosition, view);
        }
コード例 #40
0
 //-----------------------------------------------------------------------------
 public void SelectEvents_OnUnSelect(ObjectsEnumerator unSelectedEntities, SelectionDeviceEnum selectionDevice, Point modelPosition, Point2d viewPosition, View view)
 {
     m_parentCmd.OnUnSelect(unSelectedEntities, selectionDevice, modelPosition, viewPosition, view);
 }
コード例 #41
0
ファイル: Command.cs プロジェクト: hzm2016/ValveBlockDesign
 //-----------------------------------------------------------------------------
 public void OnUnSelect(ObjectsEnumerator unSelectedEntities, SelectionDeviceEnum selectionDevice, Point modelPosition, Point2d viewPosition, View view)
 {
     // Not implemented
 }
コード例 #42
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();
        }
コード例 #43
0
ファイル: SliceGraphics.cs プロジェクト: derzzle/INV2016_TRN
        //////////////////////////////////////////////////////////////////////////////////////////////
        // First selection will be a planar face or workplane used as slicing plane
        // Subsequent selections will be graphic node, so we switch nodes visibility 
        //   to reverse the normal of slicing plane
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        void SelectEvents_OnSelect(
            ObjectsEnumerator JustSelectedEntities, 
            SelectionDeviceEnum SelectionDevice, 
            Point ModelPosition, 
            Point2d ViewPosition, 
            View View)
        {
            if (JustSelectedEntities[1] is GraphicsNode)
            {
                SwitchNodesVisibility();
                return;
            }

            _interactionManager.ClearSelectionFilters();

            SetModelVisibility(false);

            switch (AdnInventorUtilities.InvApplication.ActiveDocument.DocumentType)
            { 
                case DocumentTypeEnum.kAssemblyDocumentObject:

                    foreach (ComponentOccurrence occurrence in _compDef.Occurrences)
                    {
                        occurrence.Visible = false;
                    }
                    break;

                case DocumentTypeEnum.kPartDocumentObject:

                    foreach (KeyValuePair<SurfaceBody, SurfaceBody> pair in _surfaceBodies)
                    {
                        pair.Key.Visible = false;
                    }
                    break;

                default:
                    return;
            }

            Plane plane1 = AdnInventorUtilities.GetPlane(JustSelectedEntities[1]);

            _nodes1 = CreateSlicedNodes(plane1, false);

            Vector normal2 = plane1.Normal.AsVector();
            normal2.ScaleBy(-1.0);

            Plane plane2 = 
                AdnInventorUtilities.InvApplication.TransientGeometry.CreatePlane(
                    plane1.RootPoint, 
                    normal2);

            _nodes2 = CreateSlicedNodes(plane2, true);

            _clientGraphicsMng.UpdateView();
        }