Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Access iProperties of apart in an Assembly from a Drawing

5 REPLIES 5
Reply
Message 1 of 6
fsdolphin
393 Views, 5 Replies

Access iProperties of apart in an Assembly from a Drawing

Hi,

 

I have a drawing with an assembly in it and I would like to be able to access the iProperties of the parts used in the assembly to do some comparison.

 

With the following code, I'm able to iterate through all of the parts and get their names, but the one thing I haven't been able to figure out is how to get their description from their iProperties.

 

Sub Main()
    Dim oDoc As DrawingDocument
    oDoc = ThisApplication.ActiveDocument
    
    Dim oActiveSheet As Sheet
    oActiveSheet = oDoc.ActiveSheet
    
    Dim oDrawingView As DrawingView
    oDrawingView = oActiveSheet.DrawingViews(1)
    
    Dim oRefDoc As AssemblyDocument
    oRefDoc = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument
    
    Dim oAssDef As AssemblyComponentDefinition
    oAssDef = oRefDoc.ComponentDefinition
    
    Dim oOcc As ComponentOccurrence
    For Each oOcc In oAssDef.Occurrences
	         ' Here I can get the name and do some comparison.		
		 If oOcc.Name.Contains("BRKT") Then
		 	Call oDrawingView.SetVisibility(oOcc, True)
		 Else
		 	Call oDrawingView.SetVisibility(oOcc, False)
		 End If	  
		 
		 
		' ISSUE: Here is where I'm having issues getting their description. 
		If oOcc.iProperties.Value("Project", "Description").Contains("BRKT") Then
                  MessageBox.Show("Part contains BRKT...")
               End If
    Next    
End Sub

 

I'm getting error:

Public member 'iProperties' on type 'ComponentOccurrence' not found.

 

What am I missing?

 

5 REPLIES 5
Message 2 of 6
JamieVJohnson2
in reply to: fsdolphin

iProperties belong to Component Definition of the Document that the Component Occurrence is referencing.

jvj
Message 3 of 6
fsdolphin
in reply to: JamieVJohnson2

Ok, but how do I reference them? Thanks.

Message 4 of 6
JamieVJohnson2
in reply to: fsdolphin

iLogic has a series of shortcuts in the system called ThisRule that is always active...  so when you type in iProperties.Value() you get 2 options from the ThisRule namespace.  the second option allows you to enter a component or document name, and it does all the background work for you.  So try this:

iProperties.Value(compOcc.Name, "DesignTrackingProperties", "Description")

 

or the full long vb.net method:

desc = GetDescription(occ.document).value

 

Public Property DesignTrackingPropertySetID As String = "{32853F0F-3444-11D1-9E93-0060B03C1CA6}"

 

    Public Function GetDescription(ByRef invDoc As Inventor.Document) As Inventor.Property
        Dim props As Inventor.PropertySet = invDoc.PropertySets.Item(Tools.DesignTrackingPropertySetID)
        Dim desc As Inventor.Property = props.Item("Description")
        Return desc
    End Function

jvj
Message 5 of 6
fsdolphin
in reply to: JamieVJohnson2

 

@JamieVJohnson2   I keep getting an error when I try...

 

iProperties.Value(oOcc.Name, "Project", "Description")

or

iProperties.Value(oOcc.Name, "DesignTrackingProperties", "Description")

 

Error:

Object reference not set to an instance of an object.

 

Thanks

 

 

Message 6 of 6
JamieVJohnson2
in reply to: fsdolphin

Object reference not set to an instance of an object...

The Object 'oOcc' (you component occurrence I presume) is currently 'nothing'.  Did you every anywhere say oOcc = something?  This is most likely happening at the point where you are attempting to get oOcc.Name.  The name of nothing is... what I can't get the name of a nothing???

 

 

Otherwise Inventor would error out with 'Parameter is Incorrect" if the .Value command didn't like the imput.

jvj

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report