iLogic iProperties example

Top  Previous  Next

Here you go:

 

Option Explicit

 

Public Sub Main()

 

   ' Get the Documents collection object.

   Dim invDocs As Documents

   invDocs = ThisApplication.Documents

   Dim sExt As String

 

   ' Iterate through the contents of the Documents collection.

   Dim invDocument As Document

   Dim SubDoc As Document

 

   Dim Asm As AssemblyDocument

   Dim DocsInAsm As DocumentsEnumerator

   Dim SubDocAsAsm As AssemblyDocument

 

   For Each invDocument In invDocs

       ' Display the full filename of the document in the Immediate window.

 

       If invDocument.DocumentType = kAssemblyDocumentObject Then

            Asm = invDocument

            DocsInAsm = Asm.AllReferencedDocuments

            MessageBox.Show ("Assembly " & invDocument.FullFileName & " has " & DocsInAsm.Count & " sub documents")

            ListUserParameters (Asm)

       End If

 

   Next

 

End Sub

 

Private Sub ListUserParameters(ByRef Asm As AssemblyDocument)

   Dim oDef As AssemblyComponentDefinition

   Dim AsmUserParams As UserParameters

   Dim AsmUserParam As UserParameter

 

   Dim doc As Document

   doc = ThisApplication.ActiveDocument

 

   ' Get the custom property set.

   Dim customPropSet As PropertySet

   customPropSet = doc.PropertySets.Item("Inventor User Defined Properties")

       

       Dim customProp As Object

       

       customProp = customPropSet.Item ("CIRCUITS")

       

   oDef = Asm.ComponentDefinition

   AsmUserParams = oDef.Parameters.UserParameters

 

   For Each AsmUserParam In AsmUserParams

       ' Debug.Print ("param is <" & UserParam.Name & ">")

       If AsmUserParam.Name = "CIRCUITS" Then

           MessageBox.Show ("CIRCUITS = " & AsmUserParam.ModelValue)

                       customProp.Value = AsmUserParam.ModelValue

       End If

   Next

 

End Sub

 

 

Enter topic text here.

Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)