Address fist level children only

Address fist level children only

c.bloedorn
Enthusiast Enthusiast
229 Views
1 Reply
Message 1 of 2

Address fist level children only

c.bloedorn
Enthusiast
Enthusiast

Hi I found this code which does almost exactly what I would like it to do. The only change I need, is for it to not use AllReferencedDocuments and instead only change the iproperty of the immediate children only. Is this possible to do?

Thanks in advance for any help!

I copied this code from @A.Acheson so credit goes to him!

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("Part Number")

'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

 

0 Likes
Accepted solutions (1)
230 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor
Accepted solution

Hi @c.bloedorn.  Have you tried simply changing this line:

oRefDocs = oAssyDoc.AllReferencedDocuments

...to this:

oRefDocs = oAssyDoc.ReferencedDocuments

I'm thinking that may do what you want.  If not, then we may switch from iterating through referenced documents to iterating through components.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)