Check to see if an iPart feature is suppressed using Inventor API

Check to see if an iPart feature is suppressed using Inventor API

Anonymous
Not applicable
431 Views
2 Replies
Message 1 of 3

Check to see if an iPart feature is suppressed using Inventor API

Anonymous
Not applicable

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 Sub

I 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?

0 Likes
432 Views
2 Replies
Replies (2)
Message 2 of 3

Owner2229
Advisor
Advisor

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
'...
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
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
0 Likes
Message 3 of 3

Anonymous
Not applicable

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." 

0 Likes