public override void StartCommand() { base.StartCommand(); base.SubscribeToEvent(Interaction.InteractionTypeEnum.kSelection); //initialize interaction previewgraphics objects //create and display the dialog m_connectCmdDlg = new ConnectCmdDlg(m_inventorApplication, this); if (m_connectCmdDlg != null) { m_connectCmdDlg.Activate(); m_connectCmdDlg.TopMost = true; m_connectCmdDlg.ShowInTaskbar = false; m_connectCmdDlg.Show(); } //initialize data members m_thisSurface = null; m_connectToSurface = null; m_thisCav = null; m_connectToCav = null; m_UCS = null; //enable interaction EnableInteraction(); }
public void readData(UserCoordinateSystem ucs) { UCS = ucs; textBoxX.Text = UCS.Transformation.Translation.X.ToString(); textBoxY.Text = UCS.Transformation.Translation.Y.ToString(); textBoxZ.Text = UCS.Transformation.Translation.Z.ToString(); }
public override void StartCommand() { base.StartCommand(); base.SubscribeToEvent(Interaction.InteractionTypeEnum.kSelection); //initialize interaction previewgraphics objects //create and display the dialog m_insertXportForm = new InsertXportForm(m_inventorApplication, this); if (m_insertXportForm != null) { m_insertXportForm.Activate(); m_insertXportForm.TopMost = true; m_insertXportForm.ShowInTaskbar = false; m_insertXportForm.Show(); AddInformation(); } //initialize this command data members m_firstFace = null; m_secondFace = null; m_UCS = null; //enable interaction EnableInteraction(); }
private void ShowUCS() { PartDocument oPartDoc; oPartDoc = (PartDocument)m_inventorApplication.ActiveDocument; PartComponentDefinition oPartCompDef; oPartCompDef = oPartDoc.ComponentDefinition; int index = 0; GetUCSIndex(m_thisSurface, ref index); UserCoordinateSystems oUCSs; oUCSs = oPartCompDef.UserCoordinateSystems; if (index == 0) { MessageBox.Show("发生错误!"); return; } m_UCS = oUCSs[index]; m_UCS.Visible = true; m_UCS.XAxis.Visible = false; m_UCS.YAxis.Visible = false; m_UCS.ZAxis.Visible = false; m_UCS.XYPlane.Visible = false; m_UCS.XZPlane.Visible = false; m_UCS.YZPlane.Visible = false; }
private void ShowUCS() { PartDocument oPartDoc; oPartDoc = (PartDocument)m_inventorApplication.ActiveDocument; PartComponentDefinition oPartCompDef; oPartCompDef = oPartDoc.ComponentDefinition; int i = JudgeFaceUcs(m_withThisFace); UserCoordinateSystems oUCSs; oUCSs = oPartCompDef.UserCoordinateSystems; m_UCS = oUCSs[i]; if (m_UCS == null) { MessageBox.Show("发生错误!"); return; } m_UCS.Visible = true; m_UCS.XAxis.Visible = false; m_UCS.YAxis.Visible = false; m_UCS.ZAxis.Visible = false; m_UCS.XYPlane.Visible = false; m_UCS.XZPlane.Visible = false; m_UCS.YZPlane.Visible = false; }
private string m_codenumber;//索引编号寻找iFeature特征 public InsertOutlineCmd() { m_highlightSet = null; m_insertOutlineForm = null; m_selectiFeature = null; m_selectFace = null; m_UCS = null; }
public AlignRequest(Inventor.Application application, Face thisFace, Face withThisFace, int direction, UserCoordinateSystem ucs, iFeature thisiFeature, iFeature withthisiFeature) { m_inventorApplication = application; m_thisFace = thisFace; m_withThisFace = withThisFace; m_direction = direction; m_UCS = ucs; m_thisiFeature = thisiFeature; m_withThisiFeature = withthisiFeature; }
public iFeatureFormCmd() { m_editCavityLibrary = null; m_withThisFace = null; m_highlightSet = null; m_Point = null; m_UCS = null; assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileInfo asmFile = new FileInfo(assembly.Location); deFaultpath = asmFile.DirectoryName + "\\CavityLibrary"; }
public EditNetCmd() { m_editNetForm = null; m_selectFace = null; m_selectiFeature = null; m_UCS = null; m_highlightSet = null; assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileInfo asmFile = new FileInfo(assembly.Location); deFaultpath = asmFile.DirectoryName + "\\CavityLibrary"; }
public ConnectCmd() { m_connectCmdDlg = null; m_thisSurface = null; m_connectToSurface = null; m_thisCav = null; m_connectToCav = null; m_UCS = null; m_highlightSet = null; }
public InsertXportCmd() { m_insertXportForm = null; m_firstFace = null; m_secondFace = null; m_highlightSet = null; m_UCS = null; m_xportID = null; assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileInfo asmFile = new FileInfo(assembly.Location); deFaultpath = asmFile.DirectoryName; filepath = deFaultpath + "\\CavityLibrary"; }
public override void ExecuteCommand()//执行命令 { m_inventorApplication.ActiveView.Update(); if (m_highlightSet != null) { this.ClearHighlight(); } if (m_UCS != null) { m_UCS.Visible = false; } double X = GetValueFromExpression(m_editCavityLibrary.tbx.Text); double Y = GetValueFromExpression(m_editCavityLibrary.tby.Text); double angle = 0.0; if (m_editCavityLibrary.checkBoxRotate.Checked) { switch (m_editCavityLibrary.comBAngle.Text) { case "0": angle = 0.0; break; case "90": angle = 1.57; break; case "180": angle = 3.14; break; case "270": angle = 4.71; break; } } m_iFeatureName = m_editCavityLibrary.tbID.Text; iFeatureFormRequest ifeatureformRequest = new iFeatureFormRequest(m_inventorApplication, m_withThisFace, filepath, filename, codename, codenumber, indexname, checkfootprint, X, Y, m_Point, angle, m_editCavityLibrary.dataportinformation); ifeatureformRequest.AddInformation(m_iFeatureName); base.ExecuteChangeRequest(ifeatureformRequest, "AppInsertiFeatureChgDef", m_inventorApplication.ActiveDocument); m_withThisFace = null; m_UCS = null; m_editCavityLibrary.btninsertsure.Enabled = false; m_editCavityLibrary.btninsert2.Enabled = false; m_selectEvents.ClearSelectionFilter(); m_selectEvents.ResetSelections(); }
public AlignCmd() { m_alignCmdDlg = null; m_thisFace = null; m_withThisFace = null; m_thisiFeature = null; m_withThisiFeature = null; m_UCS = null; m_highlightSet = null; }
public MoveCmd() { m_moveCmdDlg = null; m_selectFace = null; m_selectiFeature = null; m_UCS = null; m_previewClientGraphicsNode = null; m_pointGraphics = null; m_graphicsCoordinateSet = null; m_graphicsColorSet = null; m_graphicsColorIndexSet = null; m_highlightSet = null; }
public PlanarSketch SelectPlane(PartDocument oDoc, UserCoordinateSystem oUCS, double u1, double u2, double u3, double v1, double v2, double v3) { PlanarSketch oSketch; if (u1 >= 0 && u2 >= 0 && u3 >= 0 && v1 >= 0 && v2 < 0 && v3 < 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); } else if (u1 < 0 && u2 < 0 && u3 < 0 && v1 < 0 && v2 >= 0 && v3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); } else if (u1 < 0 && u2 < 0 && u3 < 0 && v1 < 0 && v2 >= 0 && v3 < 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.YZPlane, false); } else if (u1 >= 0 && u2 >= 0 && u3 >= 0 && v1 >= 0 && v2 < 0 && v3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.YZPlane, false); } else if (u1 >= 0 && u2 < 0 && u3 >= 0 && v1 >= 0 && v2 < 0 && v3 < 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); } else if (u1 < 0 && u2 >= 0 && u3 < 0 && v1 < 0 && v2 >= 0 && v3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); } else if (u1 < 0 && u2 < 0 && u3 < 0 && v1 < 0 && v2 < 0 && v3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.YZPlane, false); } else if (u1 < 0 && u2 < 0 && u3 < 0 && v1 < 0 && v2 < 0 && v3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.YZPlane, false); } else { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XZPlane, false); } return(oSketch); }
override protected void ButtonDefinition_OnExecute(NameValueMap context) { try { //MessageBox.Show("ERES UN CAPO"); AutodeskInventorInterop AII = new AutodeskInventorInterop(); string filename = "..\\CMUdata\\meshanid.srf"; // Parses files into location and vertex connectivity from an SRF file AII.ReadFileDataToList(filename); //log.Info("Reading meshanid.srf"); // Parses file for elements in riemanian metric matrix in 3D filename = "..\\CMUdata\\meshanid.nt3m"; AII.ReadFileDataToList_nt3m(filename); // log.Info("Reading meshanid.nt3m"); // Decomposes the Riemanian Matrix M=Q.L.Q^-1 AII.EigenDecomp3D(AII.EigenList); // log.Info("EigenDecomposition"); // log.Info("User Coordinate System"); Inventor.Application mApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") as Inventor.Application; Inventor.PartDocument oDoc = (Inventor.PartDocument)mApp.ActiveDocument; PartComponentDefinition oCompDef = default(PartComponentDefinition); //Defines a part component oCompDef = oDoc.ComponentDefinition; //Used to create a Unitvector where to store MajorAxis 2D for ellipse TransientGeometry oTG = mApp.TransientGeometry; UnitVector2d oUniVector = oTG.CreateUnitVector2d(1, 1); Point2d oPoint2d = mApp.TransientGeometry.CreatePoint2d(0, 0); Profile oProfile = default(Profile); //Creates a profile //EdgeCollection oEdge = default(EdgeCollection); Edge[] oSideEdges = new Edge[5]; //FilletFeature oFillet = default(FilletFeature); WorkPoint oWorkPoint1 = default(WorkPoint); WorkPoint oWorkPoint2 = default(WorkPoint); WorkPoint oWorkPoint3 = default(WorkPoint); UserCoordinateSystemDefinition oUCSDef = oCompDef.UserCoordinateSystems.CreateDefinition(); UserCoordinateSystem oUCS = default(UserCoordinateSystem); EigenVectorPatternSketchPlane selectPlaneToSketch = new EigenVectorPatternSketchPlane(); //ERASE THIS NOT USEFUL PartComponentDefinition oDef = oDoc.ComponentDefinition; PlanarSketch oSketch = default(PlanarSketch); ObjectCollection oFitPoints = mApp.TransientObjects.CreateObjectCollection(); Point2d oPoint2d_a = default(Point2d); SketchEllipticalArc oEllipticalArc = default(SketchEllipticalArc); SketchLine oAxis = default(SketchLine); RevolveFeature oRevolve = default(RevolveFeature); // WorkPlane oWPain = default(WorkPlane); #region "This is my life" /****************************************** COMMENT ***********************************************/ // Philippe Leefsma : [email protected] // Here is where all the pain happens // thank you for your help in advance. // Here is where I create a User defined coordinate system per each one of the features shown // I do not know if there is a way of making this faster? /****************************************** COMMENT ***********************************************/ for (int i = 0; i < AII.VertexLocation.Count; i++) { oWorkPoint1 = oCompDef.WorkPoints.AddFixed( oTG.CreatePoint( (double)AII.VertexLocation[i].origen.X, (double)AII.VertexLocation[i].origen.Y, (double)AII.VertexLocation[i].origen.Z) ); //Change here u1/10 this is to make it closer to the mm value check if needs to be chage to in oWorkPoint2 = oCompDef.WorkPoints.AddFixed( oTG.CreatePoint( (double)AII.EigenVectorValue[i].evc.u1 + (double)AII.VertexLocation[i].origen.X, (double)AII.EigenVectorValue[i].evc.u2 + (double)AII.VertexLocation[i].origen.Y, (double)AII.EigenVectorValue[i].evc.u3 + (double)AII.VertexLocation[i].origen.Z) ); //Check here maybe this is why my rotations are screwd up, instead of v1 maybe is w1 //If w is use I have a cool effect with the protution coming out of the screen oWorkPoint3 = oCompDef.WorkPoints.AddFixed( oTG.CreatePoint( (double)AII.EigenVectorValue[i].evc.v1 + (double)AII.VertexLocation[i].origen.X, (double)AII.EigenVectorValue[i].evc.v2 + (double)AII.VertexLocation[i].origen.Y, (double)AII.EigenVectorValue[i].evc.v3 + (double)AII.VertexLocation[i].origen.Z) ); //User Define Coordinate oUCSDef.SetByThreePoints(oWorkPoint1, oWorkPoint2, oWorkPoint3); oUCS = oCompDef.UserCoordinateSystems.Add(oUCSDef); oPoint2d.X = 0; oPoint2d.Y = 0; double l1 = AII.EigenVectorValue[i].evl.l1; double l2 = AII.EigenVectorValue[i].evl.l2; //Here maybe we can reduece time by pre-working these numbers double h1 = (1 / Math.Sqrt(l1)); //Check here double h2 = (1 / Math.Sqrt(l2)); //Change here to add alfa angle oUniVector.X = 1; // Math.Abs(AII.EigenVectorValue[i].evc.u1); //CHNAGE HERE 0 ,1 //if this is negative changes the direction oUniVector.Y = 0; // Math.Abs(AII.EigenVectorValue[i].evc.u2); oSketch = selectPlaneToSketch.SelectPlane(oDoc, oUCS); //Candidates for config file oWorkPoint1.Visible = false; oWorkPoint2.Visible = false; oWorkPoint3.Visible = false; oUCS.Visible = false; double PI = Math.Atan(1) * 4.0; double duoPI = 2 * PI; double sizeBubbleInverse = 3.5; //this changes the sizes in the features contracts the bubbles "SIZING METRIC" #region "Revolve and Join" oPoint2d_a = mApp.TransientGeometry.CreatePoint2d(0, 0); //Create Elliptical Arc oEllipticalArc = oSketch.SketchEllipticalArcs.Add(oPoint2d_a, oUniVector, h1 / (sizeBubbleInverse), h2 / (sizeBubbleInverse), 0, PI); oAxis = oSketch.SketchLines.AddByTwoPoints( oEllipticalArc.StartSketchPoint, oEllipticalArc.EndSketchPoint); oProfile = oSketch.Profiles.AddForSolid(); oRevolve = oDoc.ComponentDefinition.Features.RevolveFeatures.AddFull (oProfile, oAxis, PartFeatureOperationEnum.kJoinOperation); #endregion } #endregion } catch (Exception e) { MessageBox.Show(e.ToString()); } }
public PlanarSketch SelectPlane(PartDocument oDoc, UserCoordinateSystem oUCS, double u1, double u2, double u3, double v1, double v2, double v3, double w1, double w2, double w3) { PlanarSketch oSketch; if (u1 >= 0 && u2 >= 0 && u3 >= 0 && v1 < 0 && v2 < 0 && v3 >= 0 && w1 < 0 && w2 >= 0 && w3 < 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XZPlane, false); } else if (u1 < 0 && u2 < 0 && u3 < 0 && v1 >= 0 && v2 >= 0 && v3 < 0 && w1 >= 0 && w2 < 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.YZPlane, false); } else if (u1 >= 0 && u2 >= 0 && u3 < 0 && v1 >= 0 && v2 < 0 && v3 >= 0 && w1 >= 0 && w2 >= 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.YZPlane, false); } else if (u1 < 0 && u2 < 0 && u3 < 0 && v1 < 0 && v2 < 0 && v3 >= 0 && w1 < 0 && w2 >= 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.YZPlane, false); } else if (u1 >= 0 && u2 >= 0 && u3 < 0 && v1 < 0 && v2 >= 0 && v3 >= 0 && w1 >= 0 && w2 >= 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); ////*******change here } else if (u1 >= 0 && u2 >= 0 && u3 < 0 && v1 < 0 && v2 >= 0 && v3 >= 0 && w1 >= 0 && w2 < 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.YZPlane, false); } else if (u1 < 0 && u2 >= 0 && u3 >= 0 && v1 < 0 && v2 < 0 && v3 >= 0 && w1 >= 0 && w2 >= 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); } else if (u1 < 0 && u2 < 0 && u3 >= 0 && v1 >= 0 && v2 < 0 && v3 < 0 && w1 >= 0 && w2 < 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.YZPlane, false); } else if (u1 < 0 && u2 < 0 && u3 >= 0 && v1 < 0 && v2 >= 0 && v3 >= 0 && w1 >= 0 && w2 >= 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.YZPlane, false); } else if (u1 >= 0 && u2 >= 0 && u3 < 0 && v1 >= 0 && v2 < 0 && v3 < 0 && w1 >= 0 && w2 >= 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); //Here there is aproblem since there the plnae is not tangent CHANGE HERE!! } else if (u1 < 0 && u2 < 0 && u3 < 0 && v1 >= 0 && v2 < 0 && v3 < 0 && w1 >= 0 && w2 < 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.YZPlane, false); } else if (u1 < 0 && u2 < 0 && u3 >= 0 && v1 < 0 && v2 >= 0 && v3 < 0 && w1 >= 0 && w2 >= 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.YZPlane, false); } else if (u1 < 0 && u2 >= 0 && u3 >= 0 && v1 >= 0 && v2 < 0 && v3 >= 0 && w1 < 0 && w2 < 0 && w3 < 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); } else if (u1 < 0 && u2 >= 0 && u3 >= 0 && v1 >= 0 && v2 < 0 && v3 < 0 && w1 >= 0 && w2 < 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XZPlane, false); } else if (u1 < 0 && u2 >= 0 && u3 >= 0 && v1 >= 0 && v2 < 0 && v3 < 0 && w1 >= 0 && w2 < 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XZPlane, false); } else if (u1 >= 0 && u2 >= 0 && u3 >= 0 && v1 >= 0 && v2 < 0 && v3 >= 0 && w1 < 0 && w2 >= 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.YZPlane, false); } else if (u1 >= 0 && u2 >= 0 && u3 >= 0 && v1 >= 0 && v2 < 0 && v3 >= 0 && w1 < 0 && w2 < 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.YZPlane, false); } else if (u1 >= 0 && u2 >= 0 && u3 >= 0 && v1 >= 0 && v2 < 0 && v3 < 0 && w1 < 0 && w2 < 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.YZPlane, false); } else if (u1 >= 0 && u2 >= 0 && u3 >= 0 && v1 >= 0 && v2 >= 0 && v3 >= 0 && w1 >= 0 && w2 >= 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); //It could happen that everything is + and mot XY plane CHAGE HERE!! } else if (u1 >= 0 && u2 >= 0 && u3 >= 0 && v1 >= 0 && v2 < 0 && v3 >= 0 && w1 >= 0 && w2 >= 0 && w3 < 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); } else if (u1 >= 0 && u2 >= 0 && u3 >= 0 && v1 >= 0 && v2 < 0 && v3 < 0 && w1 >= 0 && w2 >= 0 && w3 < 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); } else if (u1 < 0 && u2 < 0 && u3 < 0 && v1 < 0 && v2 >= 0 && v3 < 0 && w1 >= 0 && w2 >= 0 && w3 < 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); } else if (u1 >= 0 && u2 < 0 && u3 >= 0 && v1 >= 0 && v2 < 0 && v3 < 0 && w1 < 0 && w2 < 0 && w3 < 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); } else if (u1 < 0 && u2 < 0 && u3 < 0 && v1 < 0 && v2 >= 0 && v3 >= 0 && w1 >= 0 && w2 >= 0 && w3 < 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); } else if (u1 >= 0 && u2 >= 0 && u3 < 0 && v1 < 0 && v2 >= 0 && v3 < 0 && w1 >= 0 && w2 >= 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); } else if (u1 < 0 && u2 < 0 && u3 >= 0 && v1 >= 0 && v2 < 0 && v3 < 0 && w1 >= 0 && w2 >= 0 && w3 >= 0) { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); } else { oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XZPlane, false); } return(oSketch); }
private void ShowUCS(int insertplane) { PartDocument oPartDoc; oPartDoc = (PartDocument)m_inventorApplication.ActiveDocument; PartComponentDefinition oPartCompDef; oPartCompDef = oPartDoc.ComponentDefinition; #region Use "AttribSet" to get the UCS //AttributeSet oAttibSet; //oAttibSet = m_withThisiFeature.AttributeSets["MyAttribSet"]; //Inventor.Attribute oPlaneAttribe; //oPlaneAttribe = oAttibSet["Plane"]; //int oAttribValue = (int)oPlaneAttribe.Value; //switch (oAttribValue) //{ // case 1: // m_UCS = oPartCompDef.UserCoordinateSystems[1]; // break; // case 2: // m_UCS = oPartCompDef.UserCoordinateSystems[2]; // break; // case 3: // m_UCS = oPartCompDef.UserCoordinateSystems[3]; // break; // case 4: // m_UCS = oPartCompDef.UserCoordinateSystems[4]; // break; // case 5: // m_UCS = oPartCompDef.UserCoordinateSystems[5]; // break; // case 6: // m_UCS = oPartCompDef.UserCoordinateSystems[6]; // break; //} #endregion #region Use "Line.Direction" to get the UCS if (insertplane != 0) { m_UCS = oPartCompDef.UserCoordinateSystems[insertplane]; } if (m_UCS == null) { MessageBox.Show("发生错误!"); return; } #endregion m_UCS.Visible = true; m_UCS.XAxis.Visible = false; m_UCS.YAxis.Visible = false; m_UCS.ZAxis.Visible = false; m_UCS.XYPlane.Visible = false; m_UCS.XZPlane.Visible = false; m_UCS.YZPlane.Visible = false; }
//Show the UCS for the m_withiFeature private void ShowUCS() { PartDocument oPartDoc; oPartDoc = (PartDocument)m_inventorApplication.ActiveDocument; PartComponentDefinition oPartCompDef; oPartCompDef = oPartDoc.ComponentDefinition; this.GetSelectiFeature(m_thisFace, ref m_thisiFeature); this.GetSelectiFeature(m_withThisFace, ref m_withThisiFeature); #region Use "AttribSet" to get the UCS //AttributeSet oAttibSet; //oAttibSet = m_withThisiFeature.AttributeSets["MyAttribSet"]; //Inventor.Attribute oPlaneAttribe; //oPlaneAttribe = oAttibSet["Plane"]; //int oAttribValue = (int)oPlaneAttribe.Value; //switch (oAttribValue) //{ // case 1: // m_UCS = oPartCompDef.UserCoordinateSystems[1]; // break; // case 2: // m_UCS = oPartCompDef.UserCoordinateSystems[2]; // break; // case 3: // m_UCS = oPartCompDef.UserCoordinateSystems[3]; // break; // case 4: // m_UCS = oPartCompDef.UserCoordinateSystems[4]; // break; // case 5: // m_UCS = oPartCompDef.UserCoordinateSystems[5]; // break; // case 6: // m_UCS = oPartCompDef.UserCoordinateSystems[6]; // break; //} #endregion #region Use "Line.Direction" to get the UCS WorkAxis workAxis; workAxis = oPartCompDef.WorkAxes.AddByRevolvedFace(m_withThisFace, true); Line oAxisLine; oAxisLine = workAxis.Line; UnitVector oAxisVector; oAxisVector = oAxisLine.Direction; Double[] coords = new Double[3]; oAxisVector.GetUnitVectorData(ref coords); string strCoords; strCoords = coords[0].ToString() + coords[1].ToString() + coords[2].ToString(); switch (strCoords) { case "00-1": m_UCS = oPartCompDef.UserCoordinateSystems[1]; break; case "010": m_UCS = oPartCompDef.UserCoordinateSystems[2]; break; case "-100": m_UCS = oPartCompDef.UserCoordinateSystems[3]; break; case "0-10": m_UCS = oPartCompDef.UserCoordinateSystems[4]; break; case "100": m_UCS = oPartCompDef.UserCoordinateSystems[5]; break; case "001": m_UCS = oPartCompDef.UserCoordinateSystems[6]; break; } if (m_UCS == null) { MessageBox.Show("发生错误!"); return; } #endregion m_UCS.Visible = true; m_UCS.XAxis.Visible = false; m_UCS.YAxis.Visible = false; m_UCS.ZAxis.Visible = false; m_UCS.XYPlane.Visible = false; m_UCS.XZPlane.Visible = false; m_UCS.YZPlane.Visible = false; }
private void ShowUCS() { PartDocument oPartDoc; oPartDoc = (PartDocument)m_inventorApplication.ActiveDocument; PartComponentDefinition oPartCompDef; oPartCompDef = oPartDoc.ComponentDefinition; WorkAxis workAxis; workAxis = oPartCompDef.WorkAxes.AddByRevolvedFace(m_selectFace, true); Line oAxisLine; oAxisLine = workAxis.Line; UnitVector oAxisVector; oAxisVector = oAxisLine.Direction; Double[] coords = new Double[3]; oAxisVector.GetUnitVectorData(ref coords); string strCoords; strCoords = coords[0].ToString() + coords[1].ToString() + coords[2].ToString(); switch (strCoords) { case "00-1": m_UCS = oPartCompDef.UserCoordinateSystems[1]; break; case "010": m_UCS = oPartCompDef.UserCoordinateSystems[2]; break; case "-100": m_UCS = oPartCompDef.UserCoordinateSystems[3]; break; case "0-10": m_UCS = oPartCompDef.UserCoordinateSystems[4]; break; case "100": m_UCS = oPartCompDef.UserCoordinateSystems[5]; break; case "001": m_UCS = oPartCompDef.UserCoordinateSystems[6]; break; } if (m_UCS == null) { MessageBox.Show("发生错误!"); return; } m_UCS.Visible = true; m_UCS.XAxis.Visible = false; m_UCS.YAxis.Visible = false; m_UCS.ZAxis.Visible = false; m_UCS.XYPlane.Visible = false; m_UCS.XZPlane.Visible = false; m_UCS.YZPlane.Visible = false; }
public PlanarSketch SelectPlane(PartDocument oDoc, UserCoordinateSystem oUCS) { PlanarSketch oSketch = oDoc.ComponentDefinition.Sketches.Add(oUCS.XYPlane, false); return(oSketch); }