Hallo zusammen,
ich möchte innerhalb einer .iam die Benutzerparameter von Inhaltscenter Bauteilen an die
i-Properties der Bauteile übergeben.
Das klappt soweit ganz gut.
Beim Anlegen des i-Properties “Abmessungen“ wo die Formel hinterlegt ist um die Abmaße der Bauteile wiederzugeben schaffe ich es nicht auf die Bauteil- Ebene zuzugreifen.
Das i-Propertie wir auf der Baugruppen- Ebene abgelegt.
Könnte mir da jemand sagen wo ich den Fehler habe.
Danke und Gruß
Sub Export()
Dim oApp As Application
Set oApp = ThisApplication
If Not oApp.ActiveEditDocument.DocumentType = kAssemblyDocumentObject Then
MsgBox "Funktion nur in Baugruppen verfügbar"
Exit Sub
End If
Dim oAssDoc As AssemblyDocument
Set oAssDoc = oApp.ActiveEditDocument
Dim oRefedDoc As Document
For Each oRefedDoc In oAssDoc.ReferencedDocuments
If oRefedDoc.DocumentType = kAssemblyDocumentObject Then
Call processAllSubDoc(oRefedDoc)
End If
If oRefedDoc.DocumentType = kPartDocumentObject Then
Call SetParameterOptions(oRefedDoc)
End If
If oRefedDoc.DocumentType = kPartDocumentObject Then
Call SetAbmessungOptions(oRefedDoc)
End If
Next
End Sub
Private Sub processAllSubDoc(ByVal oAssDoc As AssemblyDocument)
Dim oSubDoc As Document
Dim oPartDoc As PartDocument
For Each oSubDoc In oAssDoc.ReferencedDocuments
If oSubDoc.DocumentType = kAssemblyDocumentObject Then
Call processAllSubDoc(oSubDoc)
End If
If oSubDoc.DocumentType = kPartDocumentObject Then
Call SetParameterOptions(oSubDoc)
End If
If oSubDoc.DocumentType = kPartDocumentObject Then
Call SetAbmessungOptions(oSubDoc)
End If
Next
End Sub
Private Sub SetParameterOptions(ByVal oPartDoc As PartDocument)
Dim oFx As Parameter
For Each oFx In oPartDoc.ComponentDefinition.Parameters.UserParameters
If oFx.name = "G_L" Then
oFx.ExposedAsProperty = True
oFx.CustomPropertyFormat.PropertyType = kNumberPropertyType
oFx.CustomPropertyFormat.Precision = kZeroDecimalPlacePrecision
Exit For
End If
Next
For Each oFx In oPartDoc.ComponentDefinition.Parameters.UserParameters
If oFx.name = "G_W" Then
oFx.ExposedAsProperty = True
oFx.CustomPropertyFormat.PropertyType = kNumberPropertyType
oFx.CustomPropertyFormat.Precision = kZeroDecimalPlacePrecision
Exit For
End If
Next
For Each oFx In oPartDoc.ComponentDefinition.Parameters.UserParameters
If oFx.name = "G_H" Then
oFx.ExposedAsProperty = True
oFx.CustomPropertyFormat.PropertyType = kNumberPropertyType
oFx.CustomPropertyFormat.Precision = kZeroDecimalPlacePrecision
Exit For
End If
Next
End Sub
Private Sub SetAbmessungOptions(ByVal oPartDoc As PartDocument)
Dim oApp As Inventor.Application
Set oApp = ThisApplication
If oApp.ActiveDocument Is Nothing Then
MsgBox "Kein Dokument geöffnet"
Exit Sub
End If
Set oDoc = ThisApplication.ActiveDocument
Dim cuPropSet As PropertySet
Set cuPropSet = oDoc.PropertySets.Item("Inventor User Defined Properties")
Dim PropName As String
Dim PropValue As String
Dim NewProp As Property
Dim oExist As Boolean
oExist = False
PropName = "Abmessungen"
PropValue = "=<G_W>x<G_H>x<G_L>"
For Each i In cuPropSet
If i.DisplayName = PropName Then
i.Value = PropValue
oExist = True
End If
Next
If oExist = False Then
Set NewProp = cuPropSet.Add(PropValue, PropName)
End If
oDoc.Update
Dim invDoc As Document
Set invDoc = ThisApplication.ActiveDocument
Dim invCustomPropertySet As PropertySet
Set invCustomPropertySet = invDoc.PropertySets.Item("Inventor User Defined Properties")
Dim invTestProperty As Property
For Each invTestProperty In invCustomPropertySet
If invTestProperty.name = "Abmessungen" Then
MsgBox ("Abmessungen: " & invTestProperty.Value)
End If
Next
End Sub
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP