- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Check to see if an iPart feature is suppressed using Inventor API
Hi,
I currently have VBA code that I am using to rotate an iPart in an assembly 180 degrees:
Sub RotateAroundAxis()
Const PI = 3.14159265358979
Dim d As AssemblyDocument
Set d = ThisApplication.ActiveDocument
Dim a As WorkAxis
Set a = d.ComponentDefinition.WorkAxes(3)
Dim o As ComponentOccurrence
Set o = d.ComponentDefinition.Occurrences(1)
Dim t As TransientGeometry
Set t = ThisApplication.TransientGeometry
Dim l As Line
Set l = a.Line
Dim mRot As Matrix
Set mRot = t.CreateMatrix()
' PI / 2 => 90 deg
Call mRot.SetToRotation(PI, l.Direction.AsVector(), l.RootPoint)
Dim m As Matrix
Set m = o.Transformation
Call m.PreMultiplyBy(mRot)
o.Transformation = m
End SubI want to add a conditional statement that only rotates the iPart if a specific emboss feature ("Drain Port E2") is suppressed. How do I call out the emboss feature to see if the suppression is true or false?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey, try this:
'...
Dim o As ComponentOccurrence Set o = d.ComponentDefinition.Occurrences(1) Dim oDoc As Document Set oDoc = o.Definition.Document If oDoc.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then Exit Sub End If Dim oFT As PartFeature Set oFT = oDoc.ComponentDefinition.Features.Item("Drain Port E2") If Not oFT.Suppressed Then Exit Sub End If
'...
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I tried that out, and it gave me an "invalid procedure call or argument." I think it has to do with the fact that it's an iPart.
I created a function to call in my main sub that ended up working:
Function FindDrain(o As ComponentOccurrence) FindDrain = False Dim iPartRow As iPartTableRow Set iPartRow = o.Definition.iPartMember.Row If iPartRow.Item(17).Value = "Compute" Then FindDrain = True End If End Function
By going into Definition.iPartMember.Row, I gain access to the current occurrence's row in the iPart table. Item(17) is the column associated with Drain Port E2. In the iPart table, the feature is either set to "Compute" or "Suppress."