Use the GetNastranEntityParams() iLogic API to get the Nastran entity parameters Geometry ID, Geometry Type, and Component Name of an entity.
Syntax
GetNastranEntityParams( [ReferenceKey] As String, [GeometryID] As Integer,[GeometryType] As Integer,[ComponentName] As StringBuilder)
Parameters
| Name | Type | Description |
|---|---|---|
| ReferenceKey | String | Input parameter that specifies the string form of the reference key of the entity. The key context to be used to get the reference key has to be obtained from GetContextID() Inventor Nastran iLogic API. |
| GeometryID | Integer | Output parameter that specifies the Geometry ID of the entity. |
| GeometryType | Integer | Output parameter that specifies the Geometry Type of the entity. |
| ComponentName | StringBuilder | Output parameter that specifies the Component Name of the entity. |
Sample Script
AddReference "NINIlogic"
Public Module Module1
Public Dim AddinObj As New NINIlogic.InCadAddin
Public Dim strKey As String
End Module
Sub Main()
' Get Geom ID, Geom Type & Component Name from key
Dim iRet, iGeomID, iGeomType As Integer
Dim strCompName As New System.Text.StringBuilder(512)
strKey = ""
GetBRepRefKeys()
msg = MsgBox("calling GetNEEntityParams", vbOKOnly, "API call")
iRet = AddinObj.GetNastranEntityParams(strKey, iGeomID, iGeomType, strCompName)
sMsg = "GeomID = " & iGeomID
MessageBox.Show(sMsg)
sMsg = "GeomType = " & iGeomType
MessageBox.Show(sMsg)
sMsg = "strCompName = " & strCompName.ToString
MessageBox.Show(sMsg)
iLogicVb.UpdateWhenDone = True
End Sub
Sub GetBRepRefKeys()
' Get the active document.
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
Dim oSelectSet As SelectSet
oSelectSet = oDoc.SelectSet
If oSelectSet.Count = 0 Then
msg = MsgBox("Please select an entity (face/edge/vertex) & re-run the rule.", vbOKOnly, "Select entity")
Return
' Check to make sure a single item was selected.
ElseIf oSelectSet.Count <> 1 Then
msg = MsgBox("Please select only 1 entity (face/edge/vertex) & re-run the rule.", vbOKOnly, "Invalid selection")
Return
End If
Dim oFace As Face
Dim oEdge As Edge
Dim oVertex As Vertex
Dim i As Integer
' if face was selected
If TypeOf oSelectSet.Item(1) Is Face Then
' Set a reference to the selected face.
msg = MsgBox("Face selected", vbOKOnly, "Selected entity")
oFace = oSelectSet.Item(1)
i = 0
' if edge was selected
ElseIf TypeOf oSelectSet.Item(1) Is Edge Then
' Set a reference to the selected edge.
msg = MsgBox("Edge selected", vbOKOnly, "Selected entity")
oEdge = oSelectSet.Item(1)
i = 1
' if vertex was selected
ElseIf TypeOf oSelectSet.Item(1) Is Vertex Then
' Set a reference to the selected vertex.
msg = MsgBox("Vertex selected", vbOKOnly, "Selected entity")
oVertex = oSelectSet.Item(1)
i = 2
End If
' Set a reference to the ReferenceKeyManager object.
Dim refKeyMgr As ReferenceKeyManager
refKeyMgr = oDoc.ReferenceKeyManager
Dim entityRefKey(-1) As Byte
Dim keyContext As Long
' Get key context.
'keyContext = refKeyMgr.CreateKeyContext
isValid = AddinObj.GetContextID(keyContext)
If (Not isValid)
msg = MsgBox("Invalid Context", vbOKOnly, "Context validation")
Return
End If
' Get reference keys from the selected entities.
If (i = 0)
oFace.GetReferenceKey(entityRefKey, keyContext)
Else If (i = 1)
oEdge.GetReferenceKey(entityRefKey, keyContext)
Else If (i = 2)
oVertex.GetReferenceKey(entityRefKey, keyContext)
End If
strKey = refKeyMgr.KeyToString(entityRefKey)
msg = MsgBox(strKey, vbOKOnly, "Ref-Key array")
End Sub
Sample part
You can download an IPT part that has the sample script to get the key context for querying Nastran entity parameters. Click this link to download: https://knowledge.autodesk.com/support/inventor-nastran/troubleshooting/caas/downloads/content/post-ilogic-test-modelipt-for-customer-download.html