API iLogic GetNastranEntityParams()

Utilisez l’API iLogic GetNastranEntityParams() pour obtenir les paramètres d’entité Nastran ID de géométrie, type de géométrie et nom de composant d’une entité.

Syntaxe

GetNastranEntityParams( [ReferenceKey] de type chaîne, [GeometryID] de type entier,[GeometryType] de type entier,[ComponentName] de type StringBuilder)

Paramètres

Nom Type Description
ReferenceKey Chaîne Paramètre d’entrée qui spécifie la forme String de l’ID de référence de l’entité. Le contexte de l’ID à utiliser pour obtenir l’ID de référence doit être obtenu à partir de l’API iLogic GetContextID() d’Inventor Nastran.
GeometryID Entier Paramètre de sortie qui spécifie l’ID de géométrie de l’entité.
GeometryType Entier Paramètre de sortie qui spécifie le type de géométrie de l’entité.
ComponentName StringBuilder Paramètre de sortie qui spécifie le nom du composant de l’entité.

Exemple de 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

Exemple de pièce

Vous pouvez télécharger une pièce IPT qui possède l'exemple de script pour obtenir le contexte clé pour l'interrogation des paramètres d'entité Nastran. Cliquez sur ce lien pour accéder au téléchargement : https://knowledge.autodesk.com/fr/support/inventor-nastran/troubleshooting/caas/downloads/downloads/FRA/content/post-ilogic-test-modelipt-for-customer-download.html