Copy Model iProperty Settings with iLogic

Copy Model iProperty Settings with iLogic

tomas_wiklund
Contributor Contributor
4,848 Views
11 Replies
Message 1 of 12

Copy Model iProperty Settings with iLogic

tomas_wiklund
Contributor
Contributor

Hi!

 

I try to find a way to select properties to be "Copied iProperties" in a drawing.

I know how to do it in [Document Setting/Drawing/Copy Model iProperty Settings...].

Is there any way to do this with iLogic?

 

/Tomas

 

 

 

Accepted solutions (1)
4,849 Views
11 Replies
Replies (11)
Message 2 of 12

dgreatice
Collaborator
Collaborator

Hi,

 

You get bad luck for this, you only can setting Additional Custom Model iProperties Source.

 

https://forums.autodesk.com/t5/inventor-customization/externally-modify-additional-custom-model-ipro...

 

BUT, you cant select that properties list to be in "Copied iProperties". because there are no API to access to this Tool.

 

 

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 3 of 12

chandra.shekar.g
Autodesk Support
Autodesk Support

@tomas_wiklund,

 

Try below iLogic code to copy Model iProperty to Drawing Document.

 

 

Dim oPropList As ArrayList = New ArrayList()
oPropList.Add("AUTHOR")
oPropList.Add("AUTHORITY")
oPropList.Add("CATEGORY")
oPropList.Add("CHECKED BY")
oPropList.Add("CHECKED DATE") 
oPropList.Add("COMMENTS")
oPropList.Add("COMPANY")
oPropList.Add("COST CENTER")
oPropList.Add("CREATION DATE")
oPropList.Add("DESCRIPTION")
oPropList.Add("DESIGN STATE")
oPropList.Add("DESIGNER")
oPropList.Add("ENGR APPROVAL DATE")
oPropList.Add("ENGR APPROVED BY")
oPropList.Add("ENGINEER")
oPropList.Add("ESTIMATED COST")
oPropList.Add("KEYWORDS")
oPropList.Add("MANAGER")
oPropList.Add("MFG APPROVED BY")
oPropList.Add("MFG APPROVED DATE")
oPropList.Add("PART NUMBER")
oPropList.Add("PROJECT")
oPropList.Add("REVISION NUMBER")
oPropList.Add("STATUS")
oPropList.Add("STOCK NUMBER")
oPropList.Add("SUBJECT")
oPropList.Add("TITLE")
oPropList.Add("VENDOR")
oPropList.Add("WEBLINK")

sel_iProperty = InputListBox("CHOOSE iPROPERTY FROM ABOVE LIST", oPropList, oPropList.Item(0), "iPROPERTY SELECTION", "LIST OF iPROPERTY")

oRefDoc = ThisDrawing.ModelDocument
Dim oPropValue As String 

Select Case sel_iProperty 

Case "AUTHOR"
	oPropValue = oRefDoc.PropertySets("Summary Information").Item("Author").value 
	iProperties.Value("Summary", "Author") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")

Case "AUTHORITY"
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Authority").value 
	iProperties.Value("Project", "Authority") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "CATEGORY"
	oPropValue = oRefDoc.PropertySets("Document Summary Information").Item("Category").value 
	iProperties.Value("Summary", "Category") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "CHECKED BY"
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Checked By").value 
	iProperties.Value("Project", "Checked By") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "CHECKED DATE"
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Date Checked").value 
	iProperties.Value("Project", "Date Checked") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "COMMENTS"
	oPropValue = oRefDoc.PropertySets("Summary Information").Item("Comments").value 
	iProperties.Value("Summary", "Comments") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "COMPANY"
	oPropValue = oRefDoc.PropertySets("Document Summary Information").Item("Company").value 
	iProperties.Value("Summary", "Company") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "COST CENTER"
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Cost Center").value 
	iProperties.Value("Project", "Cost Center") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "CREATION DATE"
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Creation Time").value 
	iProperties.Value("Project", "Creation Time") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "DESCRIPTION"
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Description").value 
	iProperties.Value("Project", "Description") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "DESIGN STATE"
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Design Status").value 
	iProperties.Value("Project", "Design Status") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "DESIGNER"	 
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Designer").value 
	iProperties.Value("Project", "Designer") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "ENGR APPROVAL DATE"	 
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Engr Date Approved").value 
	iProperties.Value("Project", "Engr Date Approved") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "ENGR APPROVED BY"	 
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Engr Approved By").value 
	iProperties.Value("Project", "Engr Approved By") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "ENGINEER"	 
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Engineer").value 
	iProperties.Value("Project", "Engineer") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "ESTIMATED COST"	 
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Cost").value 
	iProperties.Value("Project", "Cost") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "KEYWORDS"	 
	oPropValue = oRefDoc.PropertySets("Summary Information").Item("Keywords").value 
	iProperties.Value("Summary", "Keywords") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "MANAGER"	 
	oPropValue = oRefDoc.PropertySets("Document Summary Information").Item("Manager").value 
	iProperties.Value("Summary", "Manager") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "MFG APPROVED BY"	 
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Mfg Approved By").value 
	iProperties.Value("Project", "Mfg Approved By") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "MFG APPROVED DATE"	 
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Mfg Date Approved").value 
	iProperties.Value("Project", "Mfg Date Approved") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "PART NUMBER"	 
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Part Number").value 
	iProperties.Value("Project", "Part Number") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "PROJECT"	 
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Project").value 
	iProperties.Value("Project", "Project") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "REVISION NUMBER"	 
	oPropValue = oRefDoc.PropertySets("Summary Information").Item("Revision Number").value 
	iProperties.Value("Summary", "Revision Number") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "STATUS"	 
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("User Status").value 
	iProperties.Value("Project", "User Status") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "STOCK NUMBER"	 
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Stock Number").value 
	iProperties.Value("Project", "Stock Number") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "SUBJECT"	 
	oPropValue = oRefDoc.PropertySets("Summary Information").Item("Subject").value 
	iProperties.Value("Summary", "Subject") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "TITLE"	 
	oPropValue = oRefDoc.PropertySets("Summary Information").Item("Title").value 
	iProperties.Value("Summary", "Title") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "VENDOR"
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Vendor").value 
	iProperties.Value("Project", "Vendor") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
Case "WEBLINK"
	oPropValue = oRefDoc.PropertySets("Design Tracking Properties").Item("Catalog Web Link").value 
	iProperties.Value("Project", "Catalog Web Link") = oPropValue
	MessageBox.Show(sel_iProperty + " iProperty updated successfully with value : " + oPropValue, "iProperty")
End Select

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 4 of 12

dgreatice
Collaborator
Collaborator

This method is to Copy iProperties Model and Save in iProperties Drawing.

how to copy custom iProperties Model to Custom iProperties Drawing?

 

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
Message 5 of 12

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@dgreatice,

 

Try below iLogic code to copy custom iProperty from Model to drawing document.

 

oRefDoc = ThisDrawing.ModelDocument
Dim oPropValue As String 

oPropValue = oRefDoc.PropertySets("User Defined Properties").Item("Sample").value 
iProperties.Value("Custom", "Sample") = oPropValue

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 6 of 12

dgreatice
Collaborator
Collaborator

I think you must use iteration:

 

dim oPropsets as PropertySets

oProptSets = oDoc.PropertySets.Item("User Defined Properties")

 

dim oProp as Property

 

For Each oProp in oPropSets

      'Next Code to store to object collection

      'PropList.Add oProp.Name

next

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
Message 7 of 12

tomas_wiklund
Contributor
Contributor

I did a quick test with this:

 

SyntaxEditor Code Snippet

oRefDoc = ThisDrawing.ModelDocument

oPropValue = oRefDoc.PropertySets("Summary Information").Item("Author").Value 
iProperties.Value("Summary", "Author") = oPropValue

'And for Custom Properties oPropValue = oRefDoc.PropertySets("Inventor User Defined Properties").Item("Monitor").Value iProperties.Value("Custom", "Monitor") = oPropValue

It seems to work fine. I'll be building a permanent solution later this week (perhaps).
Thanks Ihsan!

0 Likes
Message 8 of 12

Anonymous
Not applicable

This is fantastic!

 

Short simple solution, I had been looking through various posts, but this is bang on.

 

Thanks,


Sam

Message 9 of 12

matteo_pallaroni
Advocate
Advocate

Hi I'm currently testing it on Inventor 2021.3 and it returns:

(Exception HRESULT: 0x80004005 (E_FAIL))

the only change applied is:

oRefDoc = ThisDrawing.ModelDocument
Dim oPropValue As String 

oPropValue = oRefDoc.PropertySets("Inventor Document Summary Information").Item("Subject").Value 
iProperties.Value("Summery", "Subject") = oPropValue

 i tried also a step by step declaration, like:

oRefDoc = ThisDrawing.ModelDocument

'Ok here

Dim oPropsets As PropertySets
oPropsets = oRefDoc.PropertySets

'Ok here

Dim oPropset As PropertySet
oPropset = oPropsets.Item("Inventor Document Summary Information")

Dim oPropValue As [Property] 'Some unexpected brackets...????
TestValue = oPropset.Item("Subject") 'not ok

'Alternative, still not working
TestValue = oRefDoc.PropertySets("Inventor Document Summary Information").Item("Subject").Value

no idea...

0 Likes
Message 10 of 12

steveh3
Advisor
Advisor

@matteo_pallaroni 

Hello Matteo...

Attempting to use same logic. Getting same error [Exception HRESULT: 0x80004005 (E_FAIL)]

 

Did you find a resolution?

 

Best,

 

Steve Hilvers

Steve Hilvers
Inventor Certified User / Vault Professional Influencer
0 Likes
Message 11 of 12

WCrihfield
Mentor
Mentor

I don't know the scope of the task you are wanting to achieve (how many iProperties you want to copy from model document to drawing document), so I created an all inclusive iLogic rule that will attempt to copy ALL iProperties from the model to the drawing.  I had to include some Try...Catch blocks in there, because some iProperties are 'ReadOnly', and in odd cases, some special/custom PropertySets/Properties may simply not want to copy over.  I also included the use of a Transaction, to lump all this into one item in the Undo list, so it can easily be undo in one click, if needed.  This may be a bit overkill, but here it is anyways.

Dim oDrawing As DrawingDocument = ThisDrawing.Document
Dim oModel As Inventor.Document = ThisDrawing.ModelDocument
If IsNothing(oModel) Then Exit Sub
'lump all following actions into one item in the Undo List
oTrans = ThisApplication.TransactionManager.StartTransaction(oDrawing, "Copy All iProperties")
For Each oModelPropSet As PropertySet In oModel.PropertySets
	Dim oDrawingPropSet As PropertySet = Nothing
	If Not oDrawing.PropertySets.PropertySetExists(oModelPropSet.Name, oDrawingPropSet) Then
		Try
			oDrawingPropSet = oDrawing.PropertySets.Add(oModelPropSet.Name, oModelPropSet.InternalName)
		Catch
			Continue For 'PropertySet can't be copied, skip to next PropertySet
		End Try
	End If
	If oModelPropSet.Count = 0 Then Continue For
	For Each oModelProp As Inventor.Property In oModelPropSet
		'if Custom PropertySet, property might not exist yet, so check
		Dim oDrawingPropExists As Boolean = False
		If oDrawingPropSet.Count = 0 Then GoTo TryCreateProp
		For Each oDrawingProp As Inventor.Property In oDrawingPropSet
			If oDrawingProp.Name = oModelProp.Name Then
				oDrawingPropExists = True
				Try 'some iProperties are 'ReadOnly'
					oDrawingProp.Value = oModelProp.Value
					Exit For 'found so stop iterating
				Catch
				End Try
			End If
		Next 'oDrawingProp
		TryCreateProp :
		If Not oDrawingPropExists Then
			Try 'Drawing iProperty did not exist, so try to create it
				oNewDrawingProp = oDrawingPropSet.Add(oModelProp.Value, oModelProp.Name, oModelProp.PropId)
			Catch
			End Try
		End If
	Next 'oModelProp
Next 'oModelPropSet
oDrawing.Update2(True)
oTrans.End
MsgBox("Copying iProperties Task has finished.", vbInformation, "")

I also have a contribution post about just copying only all custom iProperties from the model to the drawing.  I use that one all the time.  Here is a link to that one, in case you might find it useful.

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS :bulb: or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 12 of 12

steveh3
Advisor
Advisor

@WCrihfield ....

Thanks I will take a look and see how/if I can incorporate it.

 

Best,

Steve Hilvers
Inventor Certified User / Vault Professional Influencer
0 Likes