Hello,
1) I did the following script to copy and paste some properties of the 3D to the 2D but it doesn't work when I save the 2D. If I launch the macro manually it works but can you help me to have it automatically please.
Public Sub AutoSave_MigrateProperties() ' // Normal properties // ' The following properties must be migrated: "Title", "Description", "Company", "Project" and "Part Number" ' As these properties already exist in the source (3D) and the receiver (2D), we must associate them ' WARNING: The properties are contained in the item: "Item(number which indicate the part containing the desired property)" Dim drawDoc As DrawingDocument Set drawDoc = ThisApplication.ActiveDocument drawDoc.PropertySets.Item(1).Item("Title").Value = drawDoc.Sheets.Item(1).DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item(1).Item("Title").Value drawDoc.PropertySets.Item(2).Item("Company").Value = drawDoc.Sheets.Item(1).DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item(2).Item("Company").Value drawDoc.PropertySets.Item(3).Item("Description").Value = drawDoc.Sheets.Item(1).DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item(3).Item("Description").Value drawDoc.PropertySets.Item(3).Item("Project").Value = drawDoc.Sheets.Item(1).DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item(3).Item("Project").Value drawDoc.PropertySets.Item(3).Item("Part Number").Value = drawDoc.Sheets.Item(1).DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item(3).Item("Part Number").Value ' // Custom properties // ' The following properties must be migrated: "Cat. level1" and "Cat. level2" ' For the custom propertiy, a test must be done to check if the property exists Dim invProp As Inventor.Property Dim strSourcePropVal As String On Error Resume Next For Each invProp In drawDoc.Sheets.Item(1).DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item(4) drawDoc.PropertySets.Item(4).Item(invProp.Name).Value = invProp.Value If Err Then Err.Clear Call drawDoc.PropertySets.Item(4).Add(invProp.Value, invProp.Name) End If Next End Sub
2) Once the point 1 is fixed, Is it possible to put the macro on all the 2D contained in Vault?
3) I have heard that I can do a macro or an Add-in (dll) for this job. What is the best choice?
Thank you,
Sylvain
Solved! Go to Solution.
Solved by chandra.shekar.g. Go to Solution.
Just glancing about requirement. "Copying properties from a Part/Assembly(3D) to respective Drawing(2D) on saving Drawing". Correct me if I am wrong requirement.
There are 2 solutions for current situation.
1. Creating a Drawing template with iLogic. This iLogic should be triggered by "Event Triggers". For more details about Event triggers, refer the below video link.
https://www.youtube.com/watch?v=_hY2P93pr2Y
On creating every drawing document, this template must be used.
2. Creating Addin with help of Inventor Addin wizard. For more details about Addin, refer the following link.
http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-52422162-1784-4E8F-B495-CDB7BE9987AB
In Addin, a OnSave event can be used to copying properties from 3D to 2D. The following API can be used to trigger event.
DocumentEvents.OnSave( BeforeOrAfter As EventTimingEnum, Context As NameValueMap, HandlingCode As HandlingCodeEnum )
Please feel free to contact if there is any queries.
If issue is solved, click on "Accept as solution" / give a "Kudo".
Thanks and regards,
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Hi,
The add-in works correctly but we have created a .msi to help the designers for the installation and it is better for us to manage it.
If you want the code is the following one:
Private Sub m_appEvents_OnSaveDocument( ByVal drawDoc As Inventor._Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) _ Handles m_appEvents.OnSaveDocument If BeforeOrAfter = EventTimingEnum.kBefore Then If drawDoc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then drawDoc.PropertySets.Item("Inventor Summary Information").Item("Title").Value = drawDoc.Sheets.Item(1).DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item("Inventor Summary Information").Item("Title").Value drawDoc.PropertySets.Item("Inventor Document Summary Information").Item("Company").Value = drawDoc.Sheets.Item(1).DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item("Inventor Document Summary Information").Item("Company").Value drawDoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value = drawDoc.Sheets.Item(1).DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item("Design Tracking Properties").Item("Description").Value drawDoc.PropertySets.Item("Design Tracking Properties").Item("Project").Value = drawDoc.Sheets.Item(1).DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item("Design Tracking Properties").Item("Project").Value drawDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = drawDoc.Sheets.Item(1).DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value Dim invProp As Inventor.Property Dim strSourcePropVal As String On Error Resume Next For Each invProp In drawDoc.Sheets.Item(1).DrawingViews.Item(1).ReferencedDocumentDescriptor.ReferencedDocument.PropertySets.Item("Inventor User Defined Properties") drawDoc.PropertySets.Item("Inventor User Defined Properties").Item(invProp.Name).Value = invProp.Value If (Err.Number > 0) Then Err.Clear() Call drawDoc.PropertySets.Item("Inventor User Defined Properties").Add(invProp.Value, invProp.Name) End If Next End If End If End Sub
Hi,
This is also what I am doing similar.
But what events are you using in your coding?
Are you using the Documentevents or Applicationevents to trigger the save event?
I am using the applicationevents due to some errors in the documentevents.
I do not understand what is going wrong then with your coding.
Regards,
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
I m using this:
' Inventor application object. Private m_inventorApplication As Inventor.Application Private WithEvents m_appEvents As Inventor.ApplicationEvents
Everything works correctly for me now. Why are you saying that something is going wrong?
Hi,
You wrote:
1) I did the following script to copy and paste some properties of the 3D to the 2D but it doesn't work when I save the 2D. If I launch the macro manually it works but can you help me to have it automatically please.
When it works I did misunderstand the question, sorry!
Regards,
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !
Ah ok but Chandra has provided the answer that's why I have selected his post as the answer.
Thank you for your concern
Can't find what you're looking for? Ask the community or share your knowledge.