API iLogic GetNastranEntityParams()

Utilizzare l'API iLogic GetNastranEntityParams() per ottenere i parametri dell'entità di Nastran ID geometria, tipo di geometria e nome componente di un'entità.

Sintassi

GetNastranEntityParams( [ReferenceKey] come String, [GeometryID] come Integer,[GeometryType] come Integer,[ComponentName] come StringBuilder)

Parametri

Nome Tipo Descrizione
ReferenceKey String Parametro di input che specifica il formato stringa della chiave di riferimento dell'entità. Il contesto chiave da utilizzare per ottenere la chiave di riferimento deve essere ottenuto dall'API iLogic GetContextID() di Inventor Nastran.
GeometryID Integer Parametro di output che specifica l'ID geometria dell'entità.
GeometryType Integer Parametro di output che specifica il tipo di geometria dell'entità.
ComponentName StringBuilder Parametro di output che specifica il nome del componente dell'entità.

Script di esempio

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

Parte di esempio

È possibile scaricare una parte IPT con lo script di esempio per ottenere il contesto della chiave per l'esecuzione di query sui parametri dell'entità di Nastran. Fare clic su questo collegamento per il download: https://knowledge.autodesk.com/it/support/inventor-nastran/troubleshooting/caas/downloads/downloads/ITA/content/post-ilogic-test-modelipt-for-customer-download.html