Annonces
La communauté Autodesk sera en lecture seule du 26 avril au 27 avril, le temps de réaliser une maintenance essentielle. Nous retirerons cette bannière une fois l’opération terminée. Merci pour votre compréhension.

[iLogic] Copier une liste d'iPropriétés d'un sous-ensemble ou d'une dérivée

ThomasB44
Mentor

[iLogic] Copier une liste d'iPropriétés d'un sous-ensemble ou d'une dérivée

ThomasB44
Mentor
Mentor

Bonjour,

J'ai besoin, pour un cas particulier, de copier les iPropriétés :

  • du 1er sous-ensemble, si il s'agit d'un assemblage
  • de la 1ère dérivée, si il s'agit d'une pièce

PS : j'en ai marre de chercher les bonnes expressions de chaque iPropriété, ça serait bien d'avoir la liste complète Smiley clignant de l'œil


Thomas
Mechanical Designer / Inventor Professional 2025
Inventor Professional EESignature

0 J'aime
Répondre
Solutions acceptées (1)
1 024 Visites
5 Réponses
Replies (5)

ThomasB44
Mentor
Mentor
Solution acceptée

Ci-dessous le code associé à cette demande :

 

'''This rule will copy the iProperties from :
'''The first Assembly, if it's an Assembly
'''Or the first derived Part or Assembly, if it's a Part

Dim oRefName As String
If ThisApplication.ActiveDocument.DocumentType = kAssemblyDocumentObject Then
	'Define assembly document
	Dim oAsmDoc As AssemblyDocument
	oAsmDoc = ThisApplication.ActiveDocument
	Dim oAsmDef As AssemblyComponentDefinition
	oAsmDef = oAsmDoc.ComponentDefinition
	Dim oAsmRef As ComponentOccurrence
	'Pick the first item
	oAsmRef = oAsmDef.Occurrences.Item(1)
	oRefName = oAsmRef.Name
Else If ThisApplication.ActiveDocument.DocumentType = kPartDocumentObject Then
	'Define part document
	Dim oPartDoc As PartDocument
	oPartDoc = ThisApplication.ActiveDocument
	If oPartDoc.ReferencedDocuments.Count = 0 Then Return
	Dim oDerivedRef As Inventor.Document
	'Pick the first derived document
	oDerivedRef = oPartDoc.ReferencedDocuments(1)
	oRefName = oDerivedRef.DisplayName
Else
	Return
End If
'''Copie les iPropriétés "Résumé"
'Titre
iProperties.Value("Summary", "Title") = _
iProperties.Value(oRefName, "Summary", "Title")
'Objet
iProperties.Value("Summary", "Subject") = _
iProperties.Value(oRefName, "Summary", "Subject")
'Auteur
iProperties.Value("Summary", "Author") = _
iProperties.Value(oRefName, "Summary", "Author")
'Responsable
iProperties.Value("Summary", "Manager") = _
iProperties.Value(oRefName, "Summary", "Manager")
'Société
iProperties.Value("Summary", "Company") = _
iProperties.Value(oRefName, "Summary", "Company")
'Catégorie
iProperties.Value("Summary", "Category") = _
iProperties.Value(oRefName, "Summary", "Category")
'Mots-clés
iProperties.Value("Summary", "Keywords") = _
iProperties.Value(oRefName, "Summary", "Keywords")
'Commentaires
iProperties.Value("Summary", "Comments") = _
iProperties.Value(oRefName, "Summary", "Comments")
'''Copie les iPropriétés "Projet"
'Numéro de pièce
iProperties.Value("Project", "Part Number") = _
iProperties.Value(oRefName, "Project", "Part Number")
'Numéro d'approvisionnement
iProperties.Value("Project", "Stock Number") = _
iProperties.Value(oRefName, "Project", "Stock Number")
'Description
iProperties.Value("Project", "Description") = _
iProperties.Value(oRefName, "Project", "Description")
'Numéro de révision
iProperties.Value("Project", "Revision Number") = _
iProperties.Value(oRefName, "Project", "Revision Number")
'Projet
iProperties.Value("Project", "Project") = _
iProperties.Value(oRefName, "Project", "Project")
'Concepteur
iProperties.Value("Project", "Designer") = _
iProperties.Value(oRefName, "Project", "Designer")
'Ingénieur
iProperties.Value("Project", "Engineer") = _
iProperties.Value(oRefName, "Project", "Engineer")
'Approbateur
iProperties.Value("Project", "Authority") = _
iProperties.Value(oRefName, "Project", "Authority")
'Centre de gestion
iProperties.Value("Project", "Cost Center") = _
iProperties.Value(oRefName, "Project", "Cost Center")
'Coût estimé
iProperties.Value("Project", "Cost") = _
iProperties.Value(oRefName, "Project", "Cost")
'Date de création
iProperties.Value("Project", "Creation Time") = _
iProperties.Value(oRefName, "Project", "Creation Time")
'Constructeur
iProperties.Value("Project", "Vendor") = _
iProperties.Value(oRefName, "Project", "Vendor")
'Lien Web
iProperties.Value("Project", "Catalog Web Link") = _
iProperties.Value(oRefName, "Project", "Catalog Web Link")
'''Copie les iPropriétés "Etat"
'Etat
iProperties.Value("Project", "User Status") = _
iProperties.Value(oRefName, "Project", "User Status")
'Etat de la conception
iProperties.Value("Project", "Design Status") = _
iProperties.Value(oRefName, "Project", "Design Status")
'Vérifié par
iProperties.Value("Project", "Checked By") = _
iProperties.Value(oRefName, "Project", "Checked By")
'Date de vérification
iProperties.Value("Project", "Date Checked") = _
iProperties.Value(oRefName, "Project", "Date Checked")
'Approbation pour conception par
iProperties.Value("Project", "Engr Approved By") = _
iProperties.Value(oRefName, "Project", "Engr Approved By")
'Date d'approbation pour conception
iProperties.Value("Project", "Engr Date Approved") = _
iProperties.Value(oRefName, "Project", "Engr Date Approved")
'Approbation pour fabrication par
iProperties.Value("Project", "Mfg Approved By") = _
iProperties.Value(oRefName, "Project", "Mfg Approved By")
'Date d'approbation pour fabrication
iProperties.Value("Project", "Mfg Date Approved") = _
iProperties.Value(oRefName, "Project", "Mfg Date Approved")
'''Copie les iPropriétés physiques
'Masse
iProperties.Mass = _
iProperties.Mass(oRefName)

Il est possible de modifier les iPropriétés d'aire, volume, centre de gravité, inertie...etc...mais je n'en voyais pas l'intérêt. Smiley clignant de l'œil

 

Et en PJ, la liste en PDF des iPropriétés.


Thomas
Mechanical Designer / Inventor Professional 2025
Inventor Professional EESignature

gmassart
Collaborator
Collaborator

Juste en passant, on ne peut pas boucler sur les propriétés pour éviter des les lister dans le code ?

Un boucle for each ?

Guillaume MASSART
AFFIVAL SAS
Inventor Pro 2022
EESignature

0 J'aime

ThomasB44
Mentor
Mentor

Haha je me suis dit la même chose, j'ai essayé la boucle, ça fonctionne, mais il y a des pièges à gérer...Smiley triste

Comme pour la propriété "Part Icon" de type "IpictureDisp" ou encore "Document SubType" que tu retrouveras dans le PDF joint plus haut.

 

En règle générale, on a besoin de copier seulement quelques propriétés bien précises, il faut vraiment un cas particulier comme celui que j'ai eu pour avoir besoin de les copier (presque) toutes. Smiley clignant de l'œil

 

Je reviendrai vers toi et sur ce post si j'arrive à faire une boucle en gérant ces exceptions. Smiley heureux


Thomas
Mechanical Designer / Inventor Professional 2025
Inventor Professional EESignature

0 J'aime

gmassart
Collaborator
Collaborator

Un petit select case sur le type 🙂

 

Guillaume MASSART
AFFIVAL SAS
Inventor Pro 2022
EESignature

0 J'aime

ThomasB44
Mentor
Mentor

Oui j'y ai pensé, mais ça ne suffit pas...

Par exemple dans le cas d'une pièce qui dérive un ensemble.

Que vas donner la propriété Material ?

 

Au final j'obtiens plus de questions que de réponses pour l'instant...

Je suppose que Document SubType de type String est en lecture seule, mais que se passe t il si j'essaie de l'écrire ?

Idem pour Template Row et Parameterized Template ? Est ce seulement disponible pour les dessins ?

Weld Material... ?

Defer updates... ?

 

Bref, c'est vrai que c'est séduisant de faire une boucle lol, mais pour l'instant j'ai pas assez de connaissances Smiley MDR

 


Thomas
Mechanical Designer / Inventor Professional 2025
Inventor Professional EESignature

0 J'aime