Verwenden Sie die iLogic-API GetNastranEntityParams(), um die Nastran-Objektparameter GeometryID, GeometryType und ComponentName eines Objekts abzurufen.
GetNastranEntityParams( [ReferenceKey] als Zeichenfolge, [GeometryID] als Ganzzahl,[GeometryType] als Ganzzahl,[ComponentName] als StringBuilder)
| Name | Eingabe | Beschreibung |
|---|---|---|
| ReferenceKey | Zeichenfolge | Eingabeparameter, der die Zeichenfolgenform des Referenzschlüssels des Objekts angibt. Der Schlüsselkontext zum Abrufen des Referenzschlüssels muss von der iLogic-API für Inventor Nastran GetContextID() abgerufen werden. |
| GeometryID | Ganzzahl | Ausgabeparameter, der die Geometrie-ID des Objekts angibt. |
| GeometryType | Ganzzahl | Ausgabeparameter, der den Geometrietyp des Objekts angibt. |
| ComponentName | StringBuilder | Ausgabeparameter, der den Komponentennamen des Objekts angibt. |
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
Beispiel-Bauteil
Sie können ein IPT-Bauteil mit dem Beispielskript herunterladen, um den Schlüsselkontext für die Abfrage von Nastran-Objektparametern zu erhalten. Klicken Sie zum Herunterladen auf diesen Link: https://knowledge.autodesk.com/de/support/inventor-nastran/troubleshooting/caas/downloads/downloads/DEU/content/post-ilogic-test-modelipt-for-customer-download.html