private Inventor.WorkPlane GetAssemblyDocumentWorkPlane(ref Inventor.AssemblyDocument AssemblyDocument, string WorkPlaneAffix, string WorkPlaneSuffix) { Inventor.WorkPlane DefaultWorkPlane = null; if (WorkPlaneSuffix != "") { foreach (Inventor.WorkPlane WorkPlane in AssemblyDocument.ComponentDefinition.WorkPlanes) { if (WorkPlane.Name == WorkPlaneAffix + " Plane") { return(WorkPlane); } } System.Windows.Forms.MessageBox.Show("Work Plane Not Fiound Affix: " + WorkPlaneAffix); return(DefaultWorkPlane); } else { foreach (Inventor.WorkPlane WorkPlane in AssemblyDocument.ComponentDefinition.WorkPlanes) { if (WorkPlane.Name == WorkPlaneAffix + " " + WorkPlaneSuffix) { return(WorkPlane); } } System.Windows.Forms.MessageBox.Show("Work Plane Not Fiound: Affix " + WorkPlaneAffix + " Suffix " + WorkPlaneSuffix); return(DefaultWorkPlane); } }
private void GetMaterial(ref Inventor.AssemblyDocument mAssemblyDocument) { foreach (Inventor.Material m_material in mAssemblyDocument.Materials) { cmbMaterials.Items.Add(m_material.Name); } }
private void Form1_Load(object sender, EventArgs e) { try { InvApp = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application"); } catch { System.Windows.Forms.MessageBox.Show("Starting a New Inventor Session"); } if (InvApp == null) { Type inventorAppType = System.Type.GetTypeFromProgID("Inventor.Application"); InvApp = System.Activator.CreateInstance(inventorAppType) as Inventor.Application; InvApp.Visible = true; } Inventor.Document Document = InvApp.ActiveDocument; if (Document.DocumentType == Inventor.DocumentTypeEnum.kAssemblyDocumentObject) { Inventor.AssemblyDocument AssemblyDocument = (Inventor.AssemblyDocument)Document; foreach (Inventor.OccurrencePattern OccurrencePattern in AssemblyDocument.ComponentDefinition.OccurrencePatterns) { if (OccurrencePattern.Type == Inventor.ObjectTypeEnum.kRectangularOccurrencePatternObject) { Inventor.RectangularOccurrencePattern RectangularOccurrencePattern; RectangularOccurrencePattern = (Inventor.RectangularOccurrencePattern)OccurrencePattern; foreach (Inventor.OccurrencePatternElement OccurrencePatternElement in RectangularOccurrencePattern.OccurrencePatternElements) { cmbElements.Items.Add(OccurrencePatternElement.Name); } } } } }
// ///////////////////////////////////////////////////////////////////////////////////////////////////// // Developing private void SetDocumentWorkPlanes(ref Inventor.ComponentOccurrence Occurrence, bool VisableState) { Inventor.Document Document = Occurrence.Definition.Document; if (Occurrence.DefinitionDocumentType == Inventor.DocumentTypeEnum.kPartDocumentObject) { Inventor.PartDocument PartDocument = (Inventor.PartDocument)Document; foreach (Inventor.WorkPlane WP in PartDocument.ComponentDefinition.WorkPlanes) { if (WP.Visible != VisableState) { WP.Visible = VisableState; } } } else if (Occurrence.DefinitionDocumentType == Inventor.DocumentTypeEnum.kAssemblyDocumentObject) { Inventor.AssemblyDocument AssemblyDocument = (Inventor.AssemblyDocument)Document; foreach (Inventor.WorkPlane WP in AssemblyDocument.ComponentDefinition.WorkPlanes) { if (WP.Visible != VisableState) { WP.Visible = VisableState; } } } }
public static void Run(ref Inventor.Application _InvApplication, string Type) { Inventor.AssemblyDocument assemblyDocument = (Inventor.AssemblyDocument)_InvApplication.ActiveDocument; CInvInputEvents evt = new CInvInputEvents(_InvApplication); evt.OnSelectionChange += Evt_OnSelectionChange; }
private static Inventor.GraphicsCoordinateSet SetClientGraphics(ref Inventor.AssemblyDocument assemblyDocument, ref Inventor.ClientGraphics ClientGraphics, ref Inventor.GraphicsDataSets GraphDataSets, string GraphicsName) { Inventor.AssemblyComponentDefinition ComponentDefinition = assemblyDocument.ComponentDefinition; // add ClientGraphics ClientGraphics = ComponentDefinition.ClientGraphicsCollection.Add(GraphicsName); //add GraphicsDataSets try { GraphDataSets = assemblyDocument.GraphicsDataSetsCollection[GraphicsName]; if (GraphDataSets != null) { GraphDataSets.Delete(); } } catch { } GraphDataSets = assemblyDocument.GraphicsDataSetsCollection.Add(GraphicsName); return(GraphDataSets.CreateCoordinateSet(1)); //Inventor.GraphicsCoordinateSet oCoordSet = GraphDataSets.CreateCoordinateSet(1); //return oCoordSet; }
public static void Draw(ref Inventor.Application _InvApplication, string Type) { string GraphicsName = "CG_Test"; Inventor.AssemblyDocument assemblyDocument = (Inventor.AssemblyDocument)_InvApplication.ActiveDocument; Inventor.ComponentOccurrences Occurrences = assemblyDocument.ComponentDefinition.Occurrences; if (Type == "Run") { // Test(ref _InvApplication,ref assemblyDocument, GraphicsName); //TestDrawRangeBoxs(ref _InvApplication, ref assemblyDocument, ref Occurrences, GraphicsName); Inventor.ClientGraphics ClientGraphics = null; DeleteNamedGraphics(ref assemblyDocument, GraphicsName); ClientGraphics = assemblyDocument.ComponentDefinition.ClientGraphicsCollection.Add(GraphicsName); DrawClientGraphicSolid(ref _InvApplication, ref ClientGraphics, ref assemblyDocument, "Clear - Green 1"); SetHighLightSet(ref _InvApplication, ref assemblyDocument, ref Occurrences, ""); } else { DeleteNamedGraphics(ref assemblyDocument, GraphicsName); _InvApplication.ActiveView.Update(); } // Inventor.AssemblyComponentDefinition ComponentDefinition = null; // Inventor.ClientGraphics ClientGraphics = null; }
private void InputEvents_OnSelectionChange(ref Inventor.AssemblyDocument AssemblyDocument, ref Inventor.ObjectsEnumerator JustSelected) { if (AssemblyDocument != null || JustSelected != null) { UIJustSelectedObjects = JustSelected; UIAssemblyDocument = AssemblyDocument; } }
} //Single Call private void cmbMaterials_DropDown(object sender, EventArgs e) { Inventor.Document mDocument = InvApp.ActiveDocument; if (mDocument.DocumentType == Inventor.DocumentTypeEnum.kAssemblyDocumentObject) { Inventor.AssemblyDocument mAssemblyDocument = (Inventor.AssemblyDocument)mDocument; GetMaterial(ref mAssemblyDocument); } }
private static void Test(ref Inventor.Application _InvApplication, ref Inventor.AssemblyDocument assemblyDocument, string ClientGraphicsName) { Inventor.AssemblyComponentDefinition ComponentDefinition = assemblyDocument.ComponentDefinition; // add ClientGraphics Inventor.ClientGraphics ClientGraphics = null; ClientGraphics = DeleteNamedGraphics(ref assemblyDocument, ClientGraphicsName); ClientGraphics = ComponentDefinition.ClientGraphicsCollection.Add(ClientGraphicsName); //add GraphicsDataSets Inventor.GraphicsDataSets GraphDataSets; try { GraphDataSets = assemblyDocument.GraphicsDataSetsCollection[ClientGraphicsName]; if (GraphDataSets != null) { GraphDataSets.Delete(); } } catch { } GraphDataSets = assemblyDocument.GraphicsDataSetsCollection.Add(ClientGraphicsName); Inventor.GraphicsCoordinateSet oCoordSet = GraphDataSets.CreateCoordinateSet(1); // add GraphicsNode Inventor.GraphicsNode LineNode = ClientGraphics.AddNode(1); // add LineGraphics Inventor.LineGraphics LineSet = LineNode.AddLineGraphics(); LineSet.CoordinateSet = oCoordSet; Inventor.TransientGeometry oTG = _InvApplication.TransientGeometry; oCoordSet.Add(1, oTG.CreatePoint(0, 0, 0)); oCoordSet.Add(2, oTG.CreatePoint(20, 30, 0)); oCoordSet.Add(3, oTG.CreatePoint(40, 20, 0)); oCoordSet.Add(4, oTG.CreatePoint(60, 30, 100)); // set LineDefinitionSpace as screen space LineSet.LineDefinitionSpace = Inventor.LineDefinitionSpaceEnum.kScreenSpace; // set Colour Inventor.GraphicsColorSet graphicsColorSet = LineSet.ColorSet; graphicsColorSet = GraphDataSets.CreateColorSet(1); LineSet.ColorSet = graphicsColorSet; LineSet.ColorSet.Add(1, 255, 1, 0); // set lineweight LineSet.LineWeight = 2; // set LineType LineSet.LineType = Inventor.LineTypeEnum.kChainLineType; // set LineScale LineSet.LineScale = 2; _InvApplication.ActiveView.Update(); }
public void RemoveGroup(ref Inventor.AssemblyDocument m_AssemblyDocument, String GroupName, String GroupNumber) { if (m_AssemblyDocument.SelectSet.Count == 0) { MessageBox.Show("Need to select a Part or Sub Assembly"); return; } Inventor.Assets colour = m_AssemblyDocument.Assets; foreach (var item in m_AssemblyDocument.SelectSet) { //Inventor.ComponentOccurrence occurrence = (Inventor.ComponentOccurrence)item; object objUnKnown = item; System.Type invokeType = objUnKnown.GetType(); object tmp = invokeType.InvokeMember("Type", BindingFlags.GetProperty, null, objUnKnown, null); Inventor.ObjectTypeEnum objTypeEum = (Inventor.ObjectTypeEnum)tmp; System.Diagnostics.Debug.WriteLine(objTypeEum.ToString()); if (objTypeEum == Inventor.ObjectTypeEnum.kComponentOccurrenceObject) { Inventor.ComponentOccurrence componentOccurrence = (Inventor.ComponentOccurrence)item; //(Inventor.ComponentOccurrence)objUnKnown; Inventor.AttributeSets m_AttributeSets = componentOccurrence.AttributeSets; System.Diagnostics.Debug.Print(componentOccurrence.Name + "Remove"); //Delete the attributes to the ComponentOccurrence if (m_AttributeSets.NameIsUsed[GroupName]) { m_AttributeSets[GroupName].Delete(); componentOccurrence.AppearanceSourceType = Inventor.AppearanceSourceTypeEnum.kPartAppearance; } } else if (objTypeEum == Inventor.ObjectTypeEnum.kRectangularOccurrencePatternObject) { Inventor.RectangularOccurrencePattern RectangularOccurrencePattern = (Inventor.RectangularOccurrencePattern)item; foreach (var Ritem in RectangularOccurrencePattern.OccurrencePatternElements) { Inventor.OccurrencePatternElement occurrencePatternElement = (Inventor.OccurrencePatternElement)Ritem; foreach (var Occitem in occurrencePatternElement.Occurrences) { Inventor.ComponentOccurrence componentOccurrence = (Inventor.ComponentOccurrence)Occitem; Inventor.AttributeSets m_AttributeSets = componentOccurrence.AttributeSets; if (m_AttributeSets.NameIsUsed[GroupName]) { m_AttributeSets[GroupName].Delete(); componentOccurrence.AppearanceSourceType = Inventor.AppearanceSourceTypeEnum.kPartAppearance; System.Diagnostics.Debug.Print(componentOccurrence.Name + "Remove Att and color"); } } } } } }
public CDXFExport(string PartNumberIdent, string FileSaveLocation, ref Inventor.Application InvApplication) { mInvApplication = InvApplication; PartNumberID = PartNumberIdent; FaceViews = new CDrawingView(ref InvApplication); Inventor.AssemblyDocument AssemblyDocument = (Inventor.AssemblyDocument)mInvApplication.ActiveDocument; GetAllPartsInBom(ref AssemblyDocument); }
public CDXFExport(ref System.Windows.Forms.ListBox ListBoxComponents, string PartNumberIdent, string FileSaveLocation, ref Inventor.Application InvApplication) { mInvApplication = InvApplication; ListComponents = ListBoxComponents; PartNumberID = PartNumberIdent; FaceViews = new CDrawingView(ref InvApplication); Inventor.AssemblyDocument AssemblyDocument = (Inventor.AssemblyDocument)mInvApplication.ActiveDocument; GetAllPartsInBom(ref AssemblyDocument); }
private void SaveAssemblyFile(ref Inventor.AssemblyDocument AssemblyDocument) { InvApp.SilentOperation = true; if (System.IO.File.Exists(szAssemblyFileNamePath)) { System.IO.File.Delete(szAssemblyFileNamePath); } AssemblyDocument.SaveAs(szAssemblyFileNamePath, false); AssemblyDocument.Close(true); InvApp.SilentOperation = false; }
private void CreateConstraints(ref Inventor.AssemblyDocument AssemblyDocument, ref Inventor.ComponentOccurrence BaseComponentOccurrence, Inventor.ComponentOccurrence PositionComponentOccurrence, string BaseWorkPlaneName, string PositionMateWorkPlaneName, string Affix, string Seperator, string Suffix) { Inventor.WorkPlane BaseWorkPlane = null; Inventor.WorkPlane PositionWorkPlane = null; BaseWorkPlane = GetAssemblyDocumentWorkPlane(ref AssemblyDocument, "", ""); PositionWorkPlane = GetAssemblyDocumentWorkPlane(ref AssemblyDocument, "", ""); if (BaseWorkPlane.Type == Inventor.ObjectTypeEnum.kWorkPlaneObject && PositionWorkPlane.Type == Inventor.ObjectTypeEnum.kWorkPlaneObject) { } }
private Inventor.WorkPlane GetAssemblyDocumentWorkPlane(ref Inventor.AssemblyDocument AssemblyDocument, string WorkPlaneSuffix) { Inventor.WorkPlane DefaultWorkPlane = AssemblyDocument.ComponentDefinition.WorkPlanes[3]; foreach (Inventor.WorkPlane WorkPlane in AssemblyDocument.ComponentDefinition.WorkPlanes) { if (WorkPlane.Name == WorkPlaneSuffix + " Plane") { return(WorkPlane); } } return(DefaultWorkPlane); }
private static void SetHighLightSet(ref Inventor.AssemblyDocument assemblyDocument, ref Inventor.ObjectCollection objectCollection) { if (objectCollection.Count >= 1) { Inventor.HighlightSet highlightSet = assemblyDocument.HighlightSets.Add(); //highlightSet.Color = _InvApplication.TransientObjects.CreateColor(0, 0, 255, 1); //highlightSet.Color = _InvApplication.TransientObjects.CreateColor(255, 0, 0, 1); highlightSet.AddMultipleItems(objectCollection); } else { return; } }
public static Inventor.ClientGraphics DeleteNamedGraphics(ref Inventor.AssemblyDocument assemblyDocument, string Name)//, Inventor.ClientGraphics oClientGraphics) { Inventor.ClientGraphics ClientGraphics = null; try { ClientGraphics = assemblyDocument.ComponentDefinition.ClientGraphicsCollection[Name]; if (ClientGraphics != null) { ClientGraphics.Delete(); } } catch { } return(ClientGraphics); }
private void UserInputEvents_OnSelect(Inventor.ObjectsEnumerator JustSelectedEntities, ref Inventor.ObjectCollection MoreSelectedEntities, Inventor.SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View) { if (View.Parent != null) { Inventor.Document Document = (Inventor.Document)View.Parent; Inventor.AssemblyDocument AssemblyDocument = (Inventor.AssemblyDocument)Document; if (JustSelectedEntities.Count > 0) { for (int i = JustSelectedEntities.Count; i >= 1; i--) { GetInventorObjType(JustSelectedEntities[i]); } } } }
private static Inventor.ClientGraphics DeleteClientGraphics(ref Inventor.AssemblyDocument assemblyDocument, ref Inventor.AssemblyComponentDefinition CompDef)//, Inventor.ClientGraphics oClientGraphics) { CompDef = assemblyDocument.ComponentDefinition; Inventor.ClientGraphics ClientGraphics = null; try { ClientGraphics = CompDef.ClientGraphicsCollection["CG_Test"]; if (ClientGraphics != null) { ClientGraphics.Delete(); } } catch { } return(ClientGraphics); }
private void UserInputEvents_OnSelect(Inventor.ObjectsEnumerator JustSelectedEntities, ref Inventor.ObjectCollection MoreSelectedEntities, Inventor.SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View) { if (View.Parent != null) { Inventor.Document Document = (Inventor.Document)View.Parent; if (Document.DocumentType == Inventor.DocumentTypeEnum.kAssemblyDocumentObject) { Inventor.AssemblyDocument AssemblyDocument = (Inventor.AssemblyDocument)Document; OnSelectionChange(ref AssemblyDocument, ref MoreSelectedEntities); } else { Inventor.AssemblyDocument AssemblyDocument = null; JustSelectedEntities = null; OnSelectionChange(ref AssemblyDocument, ref MoreSelectedEntities); } } }
public void AddForAttributes(Inventor.AssemblyDocument m_AssemblyDocument, Inventor.SelectSet selectSet, string GroupName, int cnt) { // int cnt = m_AssemblyDocument.SelectSet.Count; // Inventor.SelectSet selectSet = m_AssemblyDocument.SelectSet; // m_AssemblyDocument.SelectSet.GetEnumerator().Current.GetType(); for (int i = cnt; i >= 1; i--) { // object itm = selectSet[i]; try { object objUnKnown = selectSet[i]; System.Type invokeType = objUnKnown.GetType(); object tmp = invokeType.InvokeMember("Type", BindingFlags.GetProperty, null, objUnKnown, null); Inventor.ObjectTypeEnum objTypeEum = (Inventor.ObjectTypeEnum)tmp; if (objTypeEum == Inventor.ObjectTypeEnum.kComponentOccurrenceObject) { Inventor.ComponentOccurrence componentOccurrence = (Inventor.ComponentOccurrence)objUnKnown; Inventor.AttributeSets m_AttributeSets = componentOccurrence.AttributeSets; if (!(m_AttributeSets is null)) { // Add the attributes to the ComponentOccurrence Name = "GroupObject"; if (!m_AttributeSets.NameIsUsed[GroupName]) { Inventor.AttributeSet m_AttributeSet = m_AttributeSets.Add(GroupName); Inventor.Attribute m_Attribute = m_AttributeSet.Add(GroupName + "A", Inventor.ValueTypeEnum.kStringType, "G"); Inventor.Asset asset = m_AssemblyDocument.Assets["Red"]; //this to sort out componentOccurrence.Appearance = asset; } } } } catch (Exception) { MessageBox.Show("Exception"); } } }
//public CClientGraphic(ref Inventor.AssemblyDocument assemblyDocument) //{ // // Inventor.ClientGraphicsCollection clientGraphicsCollection; // //ClientGraphics //} public static void DrawRangBox(ref Inventor.Application Inv_Application, ref Inventor.AssemblyDocument assemblyDocument, Inventor.ObjectsEnumerator justSelectedEntities) { //Inventor.ComponentDefinition componentDefinition = (Inventor.ComponentDefinition)assemblyDocument.ComponentDefinition; if (justSelectedEntities.Count >= 1) { if (assemblyDocument.GraphicsDataSetsCollection.Count >= 1) { } else { Inventor.ClientGraphics clientGraphics = assemblyDocument.ComponentDefinition.ClientGraphicsCollection["RangeID"]; assemblyDocument.GraphicsDataSetsCollection["RangeID"].Delete(); clientGraphics.Delete(); } } else { return; } }
public static void DrawRangeBoxs(ref Inventor.Application Inv_Application, ref Inventor.AssemblyDocument assemblyDocument, Inventor.ObjectsEnumerator justSelectedEntities) { //Inventor.ComponentDefinition componentDefinition = (Inventor.ComponentDefinition)assemblyDocument.ComponentDefinition; if (justSelectedEntities.Count >= 1) { if (assemblyDocument.GraphicsDataSetsCollection.Count >= 1) { int length = justSelectedEntities.Count; for (int i = length - 1; i >= 0; i--) { if (GetInventorObjType(justSelectedEntities[i]) == Inventor.ObjectTypeEnum.kComponentOccurrenceObject) { Inventor.Box box = null; System.Diagnostics.Debug.WriteLine("Just Selected"); Inventor.ComponentOccurrence componentOccurrence = justSelectedEntities[i]; box = componentOccurrence.RangeBox; } //else if (GetInventorObjType(justSelectedEntities[i]) == Inventor.ObjectTypeEnum.kRectangularOccurrencePatternObject) //{ // Inventor.OccurrencePattern OccurrencePattern = justSelectedEntities[i]; // int PatternLength = 10; // for (int x = PatternLength - 1; x >= 1; x--) // { // } //} use after idea tested } } else { Inventor.ClientGraphics clientGraphics = assemblyDocument.ComponentDefinition.ClientGraphicsCollection["RangeID"]; assemblyDocument.GraphicsDataSetsCollection["RangeID"].Delete(); clientGraphics.Delete(); } } else { return; } }
public void HideOrShowGroup(ref Inventor.AssemblyDocument m_AssemblyDocument, bool hide, String GroupName, String GroupNumber) { try { Inventor.AttributeManager attbMan = m_AssemblyDocument.AttributeManager; Inventor.ObjectCollection objCol = default(Inventor.ObjectCollection); objCol = attbMan.FindObjects(GroupName, GroupName + "A", "G"); Inventor.ComponentOccurrence componentoccurrence = default(Inventor.ComponentOccurrence); int length = objCol.Count; for (int i = 1; i <= length; i++) { componentoccurrence = (Inventor.ComponentOccurrence)objCol[i]; componentoccurrence.Visible = hide; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Problem hiding component"); } }
//CGroup Group; //String NamedGroup = "GroupObject"; //String Number = "01"; public UserGUI() { InitializeComponent(); try { m_InvApplication = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application"); } catch { if (System.Windows.Forms.MessageBox.Show("Trying to Open a new instance of Autodesk Inventor", "Inventor Error", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.OK) { return; //To Caller } } if (m_InvApplication == null) { try { Type inventorAppType = System.Type.GetTypeFromProgID("Inventor.Application"); m_InvApplication = System.Activator.CreateInstance(inventorAppType) as Inventor.Application; m_InvApplication.Visible = bInventorVisable; // _started = true; } catch { System.Windows.Forms.MessageBox.Show("Can Not Open Autodesk Inventor " + Environment.NewLine + "See Your Administrator", "Instalation Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Question); // _started = false; return; } } //_started = true; // Group = new CGroup(); InputEvents = new CInventorInputEvents(m_InvApplication); InputEvents.OnSelectionChange += new CInventorInputEvents.CInventorEvents_OnSelect_DelegateHandler(InputEvents_OnSelectionChange); UIJustSelectedObjects = null; UIAssemblyDocument = null; GetApplicationHighLightColour(); }
private static void AddForAttributes(ref Inventor.AssemblyDocument m_AssemblyDocument, Inventor.SelectSet selectSet, string GroupName, int cnt) { // int cnt = m_AssemblyDocument.SelectSet.Count; // Inventor.SelectSet selectSet = m_AssemblyDocument.SelectSet; // m_AssemblyDocument.SelectSet.GetEnumerator().Current.GetType(); for (int i = 1; i <= cnt; i++) { // object itm = selectSet[i]; object objUnKnown = selectSet[i]; System.Type invokeType = objUnKnown.GetType(); object tmp = invokeType.InvokeMember("Type", BindingFlags.GetProperty, null, objUnKnown, null); Inventor.ObjectTypeEnum objTypeEum = (Inventor.ObjectTypeEnum)tmp; if (objTypeEum == Inventor.ObjectTypeEnum.kComponentOccurrenceObject) { Inventor.ComponentOccurrence componentOccurrence = (Inventor.ComponentOccurrence)objUnKnown; Inventor.AttributeSets m_AttributeSets = componentOccurrence.AttributeSets; // System.Diagnostics.Debug.Print(componentOccurrence.Name); // System.Diagnostics.Debug.Print("Counter: " + i.ToString()); if (!(m_AttributeSets is null)) { // Add the attributes to the ComponentOccurrence Name = "GroupObject"; if (!m_AttributeSets.NameIsUsed[GroupName]) { Inventor.AttributeSet m_AttributeSet = m_AttributeSets.Add(GroupName); Inventor.Attribute m_Attribute = m_AttributeSet.Add(GroupName + "A", Inventor.ValueTypeEnum.kStringType, "G"); Inventor.Asset asset = m_AssemblyDocument.Assets["Red"]; //this to sort out componentOccurrence.Appearance = asset; } } } } }
private static void ColourOccurance(Inventor.AssemblyDocument AssemblyDocument, Inventor.ComponentOccurrence componentOccurrence, string Colour) { Inventor.Asset asset = AssemblyDocument.Assets[Colour]; //this to sort out componentOccurrence.Appearance = asset; }
/// <summary> /// Attempts to connect to an open Inventor Application instance and the active assembly document. /// </summary> /// <returns>true if successful, false if failed</returns> public static bool Connect() { try { INVENTOR_APPLICATION = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application"); INVENTOR_APPLICATION.ApplicationEvents.OnQuit += ApplicationEvents_OnQuit; INVENTOR_APPLICATION.ApplicationEvents.OnCloseDocument += ApplicationEvents_OnCloseDocument; } catch { return(false); } ASSEMBLY_DOCUMENT = null; if (fullDocumentName.Equals("undef")) { if (INVENTOR_APPLICATION.Documents.VisibleDocuments.OfType <Inventor.AssemblyDocument>().Count() > 0) { FieldSelectForm fieldSelector = new FieldSelectForm(); if (fieldSelector.ShowDialog() == DialogResult.OK) { foreach (Inventor.Document doc in INVENTOR_APPLICATION.Documents.VisibleDocuments.OfType <Inventor.AssemblyDocument>()) { if (doc.DisplayName == fieldSelector.SelectedField) { ASSEMBLY_DOCUMENT = (Inventor.AssemblyDocument)doc; } } if (ASSEMBLY_DOCUMENT == null) { return(false); } fullDocumentName = ASSEMBLY_DOCUMENT.FullDocumentName; } else { return(false); } } else { return(false); } } else { foreach (Inventor.Document doc in INVENTOR_APPLICATION.Documents.VisibleDocuments.OfType <Inventor.AssemblyDocument>()) { if (doc.FullDocumentName == fullDocumentName) { ASSEMBLY_DOCUMENT = (Inventor.AssemblyDocument)doc; } } if (ASSEMBLY_DOCUMENT == null) { return(false); } } return(true); }
public static void TestDrawRangeBoxs(ref Inventor.Application _InvApplication, ref Inventor.AssemblyDocument assemblyDocument, ref Inventor.ComponentOccurrences Occurrences, string GraphicsName) { if (Occurrences.Count >= 1) { Inventor.ClientGraphics ClientGraphics = null; Inventor.GraphicsCoordinateSet CoordSet = null; Inventor.GraphicsDataSets GraphDataSets = null; Inventor.Box box = null; DeleteNamedGraphics(ref assemblyDocument, GraphicsName); CoordSet = SetClientGraphics(ref assemblyDocument, ref ClientGraphics, ref GraphDataSets, GraphicsName); int length = Occurrences.Count; for (int i = length; i >= 1; i--) { if (GetInventorObjType(Occurrences[i]) == Inventor.ObjectTypeEnum.kComponentOccurrenceObject) { System.Diagnostics.Debug.WriteLine("Just Selected"); Inventor.ComponentOccurrence componentOccurrence = Occurrences[i]; box = componentOccurrence.RangeBox; DrawBox(ref _InvApplication, ref ClientGraphics, ref CoordSet, ref GraphDataSets, ref box); } //else if (GetInventorObjType(justSelectedEntities[i]) == Inventor.ObjectTypeEnum.kRectangularOccurrencePatternObject) //{ // Inventor.OccurrencePattern OccurrencePattern = justSelectedEntities[i]; // int PatternLength = 10; // for (int x = PatternLength - 1; x >= 1; x--) // { // } //} use after idea tested } } else { return; } }