Parameter von einer Baugruppe, mittels iLogic, in ein Bauteil mit ModelStates schreiben - Write parameters from an assembly to a part with Model States using iLogic

Parameter von einer Baugruppe, mittels iLogic, in ein Bauteil mit ModelStates schreiben - Write parameters from an assembly to a part with Model States using iLogic

f.danecker
Contributor Contributor
951Aufrufe
3Antworten
Nachricht 1 von 4

Parameter von einer Baugruppe, mittels iLogic, in ein Bauteil mit ModelStates schreiben - Write parameters from an assembly to a part with Model States using iLogic

f.danecker
Contributor
Contributor

Hallo,

 

wenn man einen Parameter von einer Baugruppe, mittels iLogic, in ein Bauteil schreiben möchte ist das einfach möglich durch folgende Zeile :

[translated with Google]

Hello,

 

if you want to write a parameter from an assembly to a component using iLogic, this is easily possible with the following line:

Parameter("elbow", "material") = material

Will man jedoch das gleich machen, wenn das Bauteil Modellzustände enthält, bekommt man eine Fehlermeldung, da vermutlich nicht definiert wurde auf welchen Modelzustand man den Parameter übergeben möchte. 

Gibt es hier eine Möglichkeit wie man den Parameter auf einen bestimmten Modellzustand bzw. auf alle Modellzustände übergeben kann?

[translated with Google]

However, if you want to do the same if the component contains model states, you will get an error message, since it is likely that the model state to which the parameter is to be passed has not been defined.

Is there a way to transfer the parameter to a specific model state or to all model states?

0 „Gefällt mir“-Angaben
952Aufrufe
3Antworten
Antworten (3)
Nachricht 2 von 4

vpeuvion
Advocate
Advocate

Hello,

You can use these lines of code to extend it to all model states or just the active one.

ThisDoc.FactoryDocument.ComponentDefinition.ModelStates.MemberEditScope = MemberEditScopeEnum.kEditAllMembers

 

ThisDoc.FactoryDocument.ComponentDefinition.ModelStates.MemberEditScope = MemberEditScopeEnum.kEditActiveMember

This post should help you :

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/update-parameter-using-ilogic-in-all...

Vincent.

0 „Gefällt mir“-Angaben
Nachricht 3 von 4

f.danecker
Contributor
Contributor

Ich habe das Problem jetzt mit folgender Regel lösen können:

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oelbowOcc As ComponentOccurrence = oDoc.ComponentDefinition.Occurrences.ItemByName("elbow")
Dim elbowCompDef As PartComponentDefinition = oelbowOcc.Definition.Document.componentdefinition
Dim elbowFacDoc As PartDocument = elbowCompDef.FactoryDocument
Dim oMSs As ModelStates = elbowFacDoc.ComponentDefinition.ModelStates
Dim oActiveMS As ModelState = oMSs.ActiveModelState
oMSs.MemberEditScope = MemberEditScopeEnum.kEditActiveMember
'iPropertie Material
Dim oDTPropSet As PropertySet = elbowFacDoc.PropertySets.Item("Design Tracking Properties")
Dim oProjectProp As Inventor.Property = oDTPropSet.Item("Material")
Dim PropMaterial As String = material
'MsgBox(PropMaterial)
'Material für jeden Modellzustand im Bauteil ändern.
For Each oMS As ModelState In oMSs
    'Modellzustand aktvieieren
    oMS.Activate
    'MsgBox(oMS.Name)
    
        'hier wird die Materialbibliothek abgerufen --> Material muss in der Bibliothek vorhanden sein!
        For Each Asset_Material As MaterialAsset In ThisApplication.AssetLibraries.Item("Library").MaterialAssets
            
            'Wenn das Material gefunden wird, dann wird dieses in den iProperties für den aktiven Modellzustand geändert
            If Asset_Material.DisplayName = material Then
                ThisApplication.ActiveMaterialLibrary = ThisApplication.AssetLibraries.Item("Library")
                'iProperties.Material = mat
                oProjectProp.Value = PropMaterial
                'MsgBox(oProjectProp.Value)
                Logger.Info("Werkstoff erfolgreich geändert")   
                Exit For
            
        End If  
        Next    
    
Next
oActiveMS.Activate
elbowFacDoc.Update2
oDoc.Update2

 

 

Nachricht 4 von 4

thomas_h_T36UT
Contributor
Contributor

Guten Tag,

 

ist es mit Ihrem Code möglich, auch nur einen oder mehrere benannte Parameter aus einer Baugruppe in eine Untergeordnete Baugruppe oder Bauteil mit Modellzuständen zu übergeben?

Vielen Dank schon einmal für Ihre Rückmeldung.

0 „Gefällt mir“-Angaben