Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am trying to write an ilogic script that will update specified properties of parts when the property is changed for the assembly and that it is in the same location. The code I have is the following:
Sub Main Dim oADoc As AssemblyDocument = ThisDoc.Document 'specify which Assembly iProperties to monitor for changes 'then when they change, their values will be pushed to the parts Dim oPropNames As New List(Of String) oPropNames.Add("REFERENCE") '<<<< CHANGE THIS AS NEEDED >>>> oPropNames.Add("ENS") '<<<< CHANGE THIS AS NEEDED >>>> oPropNames.Add("PN") '<<<< CHANGE THIS AS NEEDED >>>> oPropNames.Add("Stock Number") '<<<< CHANGE THIS AS NEEDED >>>> oPropNames.Add("Project") '<<<< CHANGE THIS AS NEEDED >>>> 'Dirty = created/edited/modified since open or last save For Each oSet As PropertySet In oADoc.PropertySets If Not oSet.Dirty Then Continue For For Each oProp As Inventor.Property In oSet If Not oProp.Dirty Then Continue For For Each oName In oPropNames If oProp.Name = oName Then PushToParts(oADoc.AllReferencedDocuments, oProp) End If Next Next Next 'MsgBox("Finished.",,"") End Sub Sub PushToParts(oRefDocs As DocumentsEnumerator, oProp As Inventor.Property) Dim oParts As List(Of PartDocument) = oRefDocs.Cast(Of Inventor.Document).Where(Function(d) _ d.DocumentType = DocumentTypeEnum.kPartDocumentObject).Cast(Of PartDocument).ToList For Each oPDoc In oParts Try oPDoc.PropertySets.Item(oProp.Parent.Name).Item(oProp.Name).Value = oProp.Value Catch 'what to do if that fails (nothing right now) End Try Next End Sub
Solved! Go to Solution.