Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Transfering iProperties from drawing into model

Mark
Participant

Transfering iProperties from drawing into model

Mark
Participant
Participant

Can any one help?

 

I'm trying to establish if there is a way to transferring the standard iProperty information from 'Revision Number' within the 2D Inventor drawing, back into the associated 3D model. I know it is possible the other way, so I would have thought there must be a way to transfer the data from the drawing back to the model.

 

Any help or suggestions would be helpful.

 

Mark

0 Likes
Reply
Accepted solutions (2)
839 Views
8 Replies
Replies (8)

Owner2229
Advisor
Advisor

Hey, it would be something like this:

 

This will do it for the first referenced document:

 

 

Dim oDoc As Document = ThisApplication.ActiveDocument
If oDoc.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
Dim oPropSet As PropertySet = oDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}") 'Project Dim RN As String = oPropSet.Item("Revision Number").Expression
Dim ModelDoc As Document = oDoc.ReferencedDocuments(1) Dim oPropSetA As PropertySet = ModelDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}") 'Project oPropSetA.Item("Revision Number").Expression = RN
ModelDoc.Save() 'Optional save

 

And this'll do it for all referenced documents:

 

Dim oDoc As Document = ThisApplication.ActiveDocument
If oDoc.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
Dim oPropSet As PropertySet = oDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}") 'Project Dim RN As String = oPropSet.Item("Revision Number").Expression
For Each ModelDoc As Document In oDoc.ReferencedDocuments Dim oPropSetA As PropertySet = ModelDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}") 'Project oPropSetA.Item("Revision Number").Expression = RN
ModelDoc.Save() 'Optional save
Next

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods

Mark
Participant
Participant

Mike

Thanks for the quick reply, however when I tried running both of the codes I get the following error message

 

Error in rule: Data Transfer, in document: Test.idw

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

 

As I'm no expert in I-Logic, it might be that I've made a simple error, so could you advise what could cause such an error message.

 

Cheers

 

Mark

0 Likes

Owner2229
Advisor
Advisor

It should be "Standard Revision" instead of "Revision Number". And the value can't be empty:

 

 

 

This will do it for the first referenced document:

 

 

Dim oDoc As Document = ThisApplication.ActiveDocument
If oDoc.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
Dim oPropSet As PropertySet = oDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}") 'Project Dim RN As String = oPropSet.Item("Standard Revision").Expression
If RN = "" Then Exit Sub
Dim ModelDoc As Document = oDoc.ReferencedDocuments(1) Dim oPropSetA As PropertySet = ModelDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}") 'Project oPropSetA.Item("Revision Number").Expression = RN
ModelDoc.Save() 'Optional save

 

And this'll do it for all referenced documents:

 

Dim oDoc As Document = ThisApplication.ActiveDocument
If oDoc.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
Dim oPropSet As PropertySet = oDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}") 'Project Dim RN As String = oPropSet.Item("Standard Revision").Expression
If RN = "" Then Exit Sub
For Each ModelDoc As Document In oDoc.ReferencedDocuments Dim oPropSetA As PropertySet = ModelDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}") 'Project oPropSetA.Item("Revision Number").Expression = RN
ModelDoc.Save() 'Optional save
Next

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes

Mark
Participant
Participant
Mike I've tried running both of these new codes. Both run without any errors, but as you'll see from the attached the 'Revision Number' in the model has remained at '1' even after the updating the drawing to revision '2' and running both codes. Have you any other suggestions, or am I missing a simple step. Cheers Mark
0 Likes

Jesper_S
Collaborator
Collaborator
Accepted solution

Hi.

 

I use this code to get iProperties from the model to the drawing.

 

SyntaxEditor Code Snippet

If (ThisDrawing.ModelDocument Is Nothing) Then Return

modelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)

'read the values from the Custom iProperties in the part file

'and apply them to the Custom iProperties with the same name in the drawing

iProperties.Value("Project", "Part Number")=iProperties.Value(modelName, "Project", "Part Number")

iProperties.Value("Summary", "Company")=iProperties.Value(modelName, "Summary", "Company")

iProperties.Value("Project", "Project")=iProperties.Value(modelName, "Project", "Project")

iProperties.Value("Summary", "Title")=iProperties.Value(modelName, "Summary", "Title")

Then i use this to send back iProperties to the model from the drawing.

 

SyntaxEditor Code Snippet

' Set a reference to the drawing document.' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

' Set a reference to the active sheet.
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

'Get the name Of the first model in the drawing
modelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)

iProperties.Value(modelName, "Project", "Part Number")=iProperties.Value("Project", "Part Number")

iProperties.Value(modelName, "Summary", "Company")=iProperties.Value("Summary", "Company")

iProperties.Value(modelName, "Project", "Project")=iProperties.Value("Project", "Project")

iProperties.Value(modelName, "Summary", "Title")=iProperties.Value("Summary", "Title")

iLogicVb.UpdateWhenDone = True

 


//Jesper

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

Mark
Participant
Participant

The code works perfectly, and is easy to add extras to.

 

Many thanks

Smiley Happy

 

Mark

0 Likes

Owner2229
Advisor
Advisor

Hey, apparently on the "Project" tab is a different type of revision (internal), so the "Revision Number" was correct, but the Property Set wasn't, try it now:

 

For first referenced document:

 

Dim oDoc As Document = ThisApplication.ActiveDocument
If oDoc.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
Dim oPropSet As PropertySet = oDoc.PropertySets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}") Dim RN As String = oPropSet.Item("Revision Number").Expression
Dim ModelDoc As Document = oDoc.ReferencedDocuments(1) Dim oPropSetA As PropertySet = ModelDoc.PropertySets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}")
oPropSetA.Item("Revision Number").Expression = RN
ModelDoc.Save() 'Optional save

 

For all referenced documents:

 

Dim oDoc As Document = ThisApplication.ActiveDocument
If oDoc.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
Dim oPropSet As PropertySet = oDoc.PropertySets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}") Dim RN As String = oPropSet.Item("Revision Number").Expression
For Each ModelDoc As Document In oDoc.ReferencedDocuments Dim oPropSetA As PropertySet = ModelDoc.PropertySets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}") oPropSetA.Item("Revision Number").Expression = RN
ModelDoc.Save() 'Optional save
Next

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes

Jesper_S
Collaborator
Collaborator
Accepted solution

Yes, it's a quite easy code.

I have them like a button in a form in my drawing for when I fill in all the properties 

for the drawing.

 

Please mark this as Accepted Solution.


//Jesper

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
0 Likes