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?
iProperties belong to Component Definition of the Document that the Component Occurrence is referencing.
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
@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
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.
Can't find what you're looking for? Ask the community or share your knowledge.