| |
 | Gut zu wissen: Hilfreiche Tipps und Tricks aus der Praxis prägnant, und auf den Punkt gebracht für Autodesk Produkte |
| |
 | PNY präsentiert die neue NVIDIA RTX A400 und die A1000 Grafikkarte, eine Pressemitteilung
|
Autor
|
Thema: Benutzer Parameter - I-Properties (1768 / mal gelesen)
|
Goose Mitglied Maschinenbautechniker / geb. Zerspanungsmechaniker Fachrichtung Frästechnik
 
 Beiträge: 207 Registriert: 29.03.2007 IV2024 R3 CATIA V6 R2013x
|
erstellt am: 20. Jul. 2017 14:29 <-- editieren / zitieren --> Unities abgeben:         
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 |
Chris 31 Mitglied Konstrukteur und Mädchen für alles
  
 Beiträge: 575 Registriert: 23.04.2013 Inventor 2013/2015 Windows 7 64 bit 16GB RAM nVidia Quadro 600
|
erstellt am: 24. Jul. 2017 08:59 <-- editieren / zitieren --> Unities abgeben:          Nur für Goose
Das könnte daran liegen, dass du zwar das Part-Doc übergibst, dann aber nicht damit weiter arbeitest. Code: 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
------------------ MFG Chris Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Goose Mitglied Maschinenbautechniker / geb. Zerspanungsmechaniker Fachrichtung Frästechnik
 
 Beiträge: 207 Registriert: 29.03.2007 IV2024 R3 CATIA V6 R2013x
|
erstellt am: 25. Jul. 2017 11:15 <-- editieren / zitieren --> Unities abgeben:         
Zitat: Original erstellt von Chris 31: Das könnte daran liegen, dass du zwar das Part-Doc übergibst, dann aber nicht damit weiter arbeitest.
Code: Private Sub SetAbmessungOptions([b]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
[/B]
Hallo Chris, Vielen Dank für den Hinweis. Könnte mir jemand sagen wo ich eine Liste der Beriffe, wie z.B. "Set oDoc = ThisApplication.ActiveDocument" mit einer Erklärungen der Funktion, finde. Danke und Gruß Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Chris 31 Mitglied Konstrukteur und Mädchen für alles
  
 Beiträge: 575 Registriert: 23.04.2013 Inventor 2013/2015 Windows 7 64 bit 16GB RAM nVidia Quadro 600
|
erstellt am: 25. Jul. 2017 11:49 <-- editieren / zitieren --> Unities abgeben:          Nur für Goose
Was meinst du mit Begriffen? Das Objektmodell von Inventor findest du hier als Download. Der Rest ist "normales" VBA. Also einfach nach VBA googlen und ein paar tutorials durchackern und dann hast es.
------------------ MFG Chris Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Goose Mitglied Maschinenbautechniker / geb. Zerspanungsmechaniker Fachrichtung Frästechnik
 
 Beiträge: 207 Registriert: 29.03.2007 IV2024 R3 CATIA V6 R2013x
|
erstellt am: 25. Jul. 2017 12:58 <-- editieren / zitieren --> Unities abgeben:         
Zitat: Original erstellt von Chris 31: Was meinst du mit Begriffen?Das Objektmodell von Inventor findest du hier als Download. Der Rest ist "normales" VBA. Also einfach nach VBA googlen und ein paar tutorials durchackern und dann hast es.
Hallo Chris, Danke für den Link! Gruß Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Chris 31 Mitglied Konstrukteur und Mädchen für alles
  
 Beiträge: 575 Registriert: 23.04.2013 Inventor 2013/2015 Windows 7 64 bit 16GB RAM nVidia Quadro 600
|
erstellt am: 26. Jul. 2017 07:44 <-- editieren / zitieren --> Unities abgeben:          Nur für Goose
|
Goose Mitglied Maschinenbautechniker / geb. Zerspanungsmechaniker Fachrichtung Frästechnik
 
 Beiträge: 207 Registriert: 29.03.2007 IV2024 R3 CATIA V6 R2013x
|
erstellt am: 22. Aug. 2017 10:53 <-- editieren / zitieren --> Unities abgeben:         
Hallo zusammen, das Mako macht jetzt soweit was es soll. Ich würde nur gerne noch eine Abfrage mit einbringen in welcher Blech-Bauteile von der Belegung mit dem Parameter "Abmessungen" ausgeschlossen werden. Wie kann man Blechteile schon im Vorfeld ausklammern? Ein Beispiel wäre schön! Danke und Gruß.
Code: 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 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 For Each oFx In oPartDoc.ComponentDefinition.Parameters.UserParameters If oFx.name = "G_T" Then oFx.ExposedAsProperty = True oFx.CustomPropertyFormat.PropertyType = kNumberPropertyType oFx.CustomPropertyFormat.Precision = kZeroDecimalPlacePrecision Exit For End If Next End Sub Private Sub SetAbmessungOptions() Dim asmDoc As AssemblyDocument Set asmDoc = ThisApplication.ActiveDocument ' Iterate through all of the referenced documents at ' all levels of the assembly. Dim doc As Document For Each doc In asmDoc.AllReferencedDocuments ' Check for part documents. If doc.DocumentType = kPartDocumentObject Then ' Call the function to update the part. Call UpdateParameter(doc) End If Next End Sub Private Sub UpdateParameter(part As PartDocument) 'Get the User Defined Properties. Dim cuPropSet As PropertySet Set cuPropSet = _ part.PropertySets.Item("Inventor User Defined Properties") 'Check to see if the parameter already exists. 'Dim param As PropertySet 'On Error Resume Next 'Set param = cuPropSet.Item("Abmessungen") 'On Error GoTo 0 PropName = "Abmessungen" PropValue = "=<G_W>x<G_H>x<G_T>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 End Sub
[Diese Nachricht wurde von Goose am 22. Aug. 2017 editiert.] Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Ticky72 Mitglied

 Beiträge: 35 Registriert: 17.02.2016 Inventor 2019 Win7 64Bit
|
erstellt am: 22. Aug. 2017 11:54 <-- editieren / zitieren --> Unities abgeben:          Nur für Goose
|
Goose Mitglied Maschinenbautechniker / geb. Zerspanungsmechaniker Fachrichtung Frästechnik
 
 Beiträge: 207 Registriert: 29.03.2007 IV2024 R3 CATIA V6 R2013x
|
erstellt am: 01. Sep. 2017 08:41 <-- editieren / zitieren --> Unities abgeben:         
Hi, ich möcht eine Abfrage mit einbringen die prüft welche Parameter ausgelesen werden konnten. Wenn beispielsweise ParT,ParH und b ausgelesen werden konnten soll in den Properties unter „Abmessungen“ Eintrag XYZ erfolgen. Wenn Parameter G_W, G_L…. ausgelesen werden konnten soll unter den Abmessungen der Eintrag ABC erfolgen. Wie kann man so etwas umsetzen? Und eine Frage zu Formatierung: Bei kThreeDecimalPlacesPrecision wird das“,“ (Komma) immer mit geschrieben auch wenn keine Nachkommastellen vorhanden sind. Bsp. : Wert 50 wird 50, angezeigt Wie kann ich das entsprechend umsetzen? Danke und Gruß
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Chris 31 Mitglied Konstrukteur und Mädchen für alles
  
 Beiträge: 575 Registriert: 23.04.2013 Inventor 2013/2015 Windows 7 64 bit 16GB RAM nVidia Quadro 600
|
erstellt am: 01. Sep. 2017 09:26 <-- editieren / zitieren --> Unities abgeben:          Nur für Goose
Hi, zur Abfrage, welche Parameter ausgelesen werden können, kannst du ähnlich vorgehen, wie es in der Sub SetParameterOptions(ByVal oPartDoc As PartDocument) schon gemacht wird. könnte in etwa so aussehen:
Code:
Dim oFx As Parameter For Each oFx In oPartDoc.ComponentDefinition.Parameters.UserParameters If oFx.name = "G_L" Then '*********Hier dann das Eintragen der entsprechenden Properties***** Exit For End If Next
Zu deiner Frage nach der Formatierung: Willst du das Komma jetzt angezeigt habe, oder nicht? ------------------ MFG Chris Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Goose Mitglied Maschinenbautechniker / geb. Zerspanungsmechaniker Fachrichtung Frästechnik
 
 Beiträge: 207 Registriert: 29.03.2007 IV2024 R3 CATIA V6 R2013x
|
erstellt am: 01. Sep. 2017 09:36 <-- editieren / zitieren --> Unities abgeben:         
Zitat: Original erstellt von Chris 31:Zu deiner Frage nach der Formatierung: Willst du das Komma jetzt angezeigt habe, oder nicht? [/B]
Wenn das Maß 50,0 ist sollte nur 50 angezeigt werden. Bei einem Wert von 50,5 sollte dann auch 50,5 in die Properties eingetragen werden.
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Chris 31 Mitglied Konstrukteur und Mädchen für alles
  
 Beiträge: 575 Registriert: 23.04.2013 Inventor 2013/2015 Windows 7 64 bit 16GB RAM nVidia Quadro 600
|
erstellt am: 01. Sep. 2017 12:34 <-- editieren / zitieren --> Unities abgeben:          Nur für Goose
Versuche mal: Code:
oFx.ExposedAsProperty = True oFx.CustomPropertyFormat.PropertyType = kNumberPropertyType oFx.CustomPropertyFormat.Precision = kZeroDecimalPlacePrecision oFx.CustomPropertyFormat.ShowTrailingZeros = False Exit For
------------------ MFG Chris Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |
Goose Mitglied Maschinenbautechniker / geb. Zerspanungsmechaniker Fachrichtung Frästechnik
 
 Beiträge: 207 Registriert: 29.03.2007 IV2024 R3 CATIA V6 R2013x
|
erstellt am: 01. Sep. 2017 15:25 <-- editieren / zitieren --> Unities abgeben:         
Zitat: Original erstellt von Chris 31: Versuche mal:Code:
oFx.ExposedAsProperty = True oFx.CustomPropertyFormat.PropertyType = kNumberPropertyType oFx.CustomPropertyFormat.Precision = kZeroDecimalPlacePrecision [b]oFx.CustomPropertyFormat.ShowTrailingZeros = False Exit For
[/B]
Hi, musste noch kNumberPropertyType auf kTextPropertyType umstellen.
Vielen Dank! Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP |