Hi everyone,
I'm trying to figure out how to write an external rule that will look at the top level assembly from which the rule is launched and gather the value that is entered in the Project: Project iproperty field. I want that value fed down to the sub-assembly/ part level Project: Project iproperty field. I assume it will be some sort of loop style function since I won't know exactly how many parts/sub-assemblies will be present in the top level assembly.
Solved! Go to Solution.
Solved by A.Acheson. Go to Solution.
For the iproperties I would use All Referenced Documents (1) This targets only the single file even if used in multiple sub assemblies so is the shortest route to target each documents. Then next is to loop through the documents and then actually retrieve the iproperties (2). I have left a document filter in there in case you want to filter for part/assembly documents using "kPartDocumentObject" / "kAssemblyDocumentObject".
.
Dim oAssyDoc As AssemblyDocument oAssyDoc = ThisApplication.ActiveDocument ' Get the Design Tracking property set. Dim AssyDesignPropSet As PropertySet AssyDesignPropSet = oAssyDoc.PropertySets.Item("Design Tracking Properties") ' Get the Description property. Dim AssyProj As Inventor.Property AssyProj = AssyDesignPropSet.Item("Project") 'Get all of the referenced documents. Dim oRefDocs As DocumentsEnumerator oRefDocs = oAssyDoc.AllReferencedDocuments 'Iterate through the list of documents. Dim oRefDoc As Document For Each oRefDoc In oRefDocs ' If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then ' Logger.Info("DisplayName: "& oRefDoc.DisplayName)'FileName ' Logger.Info("FullFileName: "& oRefDoc.FullFileName)'FilePath ' Get the Design Tracking property set. Dim DesignTrackPropSet As PropertySet DesignTrackPropSet = oRefDoc.PropertySets.Item("Design Tracking Properties") ' Get the Description property. Dim RefProj As Inventor.Property RefProj = DesignTrackPropSet.Item("Project") Try RefProj.Value = AssyProj.Value Catch Logger.Info("Read Only - "& oRefDoc.DisplayName ) End Try 'End If Next
Also you can use a function with Vb.Net to reduce extra lines required and to also work with other iproperties easily.
Sub Main Dim oAssyDoc As AssemblyDocument oAssyDoc = ThisApplication.ActiveDocument Dim oAssyProj As [Property] oAssyProj= GetiProp(oAssyDoc,"Project") Logger.Info(oAssyProj.Value) 'Get all of the referenced documents. Dim oRefDocs As DocumentsEnumerator oRefDocs = oAssyDoc.AllReferencedDocuments 'Iterate through the list of documents. Dim oRefDoc As Document For Each oRefDoc In oRefDocs ' If oRefDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then 'Logger.Info("DisplayName: "& oRefDoc.DisplayName)'FileName 'Logger.Info("FullDocumentName: "& oRefDoc.FullDocumentName)'FilePath Dim oRefProjNo As [Property] oRefProjNo = GetiProp(oRefDoc,"Project") Try oRefProjNo.Value = oAssyProj.Value Catch Logger.Info("Read Only - "& oRefDoc.DisplayName ) End Try 'End If Next End Sub Function GetiProp(oDoc As Document,iPropName As String)As [Property] ' Get the Design Tracking property set. Dim DesignTrackPropSet As PropertySet DesignTrackPropSet = oDoc.PropertySets.Item("Design Tracking Properties") ' Get the Description property. Dim oProjProp As Inventor.Property oProjProp = DesignTrackPropSet.Item(iPropName) Return oProjProp End Function
Hi,
Is it also possible to change the iproperty of the fist level children only. So if there is a subassembly within the main assembly to not alter the iproperties of parts within it?
Can't find what you're looking for? Ask the community or share your knowledge.