Do not overwrite existing iproperties

Do not overwrite existing iproperties

johan.degreef
Advisor Advisor
486 Views
2 Replies
Message 1 of 3

Do not overwrite existing iproperties

johan.degreef
Advisor
Advisor

Hello all,

 

I have this rule that adds all our cutom iproperties to a part that don't have them. Problem is that if 1 custom iproperty already exists in the part it get's overxritten by a new custom iproperty that is empty value. What needs do be modified that if a custom iproperty already exists, it get's skipped and not cleared?

 

iProperties.Value("Custom", "PTN_ARTNR") = ""
iProperties.Value("Custom", "PTN_CLIENT") = ""
iProperties.Value("Custom", "PTN_CLIENT_DRAWING") = ""
iProperties.Value("Custom", "PTN_CLIENT_TAG") = ""
iProperties.Value("Custom", "PTN_CODE") = ""
iProperties.Value("Custom", "PTN_COMMENTS") = ""
iProperties.Value("Custom", "PTN_DESCRIPTION_EN") = ""
iProperties.Value("Custom", "PTN_DESCRIPTION_NL") = ""
iProperties.Value("Custom", "PTN_DESCRIPTION_FR") = ""
iProperties.Value("Custom", "PTN_DESIGNER") = ""
iProperties.Value("Custom", "PTN_DRAWING") = ""
iProperties.Value("Custom", "PTN_LOCATION") = ""
iProperties.Value("Custom", "PTN_MANAGER") = ""
iProperties.Value("Custom", "PTN_MATERIAL") = ""
iProperties.Value("Custom", "PTN_PN") = ""
iProperties.Value("Custom", "PTN_PROJECTNR") = ""
iProperties.Value("Custom", "PTN_REVISION") = ""
iProperties.Value("Custom", "PTN_SIZE") = ""
iProperties.Value("Custom", "PTN_STATUS") = ""
iProperties.Value("Custom", "PTN_SUPPLIER") = ""
iProperties.Value("Custom", "PTN_TAG") = ""
iProperties.Value("Custom", "PTN_TITLE_EN") = ""
iProperties.Value("Custom", "PTN_TITLE_NL") = ""
iProperties.Value("Custom", "PTN_TITLE_FR") = ""
iProperties.Value("Custom", "PTN_TRADEMARK") = ""
iProperties.Value("Custom", "PTN_TRADEMARK_ARTNR") = ""
iProperties.Value("Custom", "PTN_TYPE") = ""
iProperties.Value("Custom", "PTN_WEIGHT") = ""
Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
0 Likes
Accepted solutions (1)
487 Views
2 Replies
Replies (2)
Message 2 of 3

J-Camper
Advisor
Advisor
Accepted solution

You can "Check" if a Property exists, by trying to set a variable to the Value of the iProperty.  Since you have a lot of iProperties, I would suggest looping through a list.

 

Try this:

Dim CustiPropsList As New List(Of String) 
CustiPropsList.AddRange({"PTN_ARTNR", "PTN_CLIENT", "PTN_CLIENT_DRAWING", "PTN_CLIENT_TAG", "PTN_CODE", "PTN_COMMENTS", _
						"PTN_DESCRIPTION_EN", "PTN_DESCRIPTION_NL", "PTN_DESCRIPTION_FR", "PTN_DESIGNER", "PTN_DRAWING", _
						"PTN_LOCATION", "PTN_MANAGER", "PTN_MATERIAL", "PTN_PN", "PTN_PROJECTNR", "PTN_REVISION", "PTN_SIZE", _
						"PTN_STATUS", "PTN_SUPPLIER", "PTN_TAG", "PTN_TITLE_EN", "PTN_TITLE_NL", "PTN_TITLE_FR", "PTN_TRADEMARK", _
						"PTN_TRADEMARK_ARTNR", "PTN_TYPE", "PTN_WEIGHT" })

For Each s As String In CustiPropsList
	Try 'Try to set a variable to the iProperty Value
		Prop = iProperties.Value("Custom", s)
	Catch 'If it fails, it doesn't exist, so make it
		iProperties.Value("Custom", s) = ""
	End Try
Next

 

It is easy to add more iProperties to the list if needed.  Let me know if you have any questions.

Message 3 of 3

johan.degreef
Advisor
Advisor

@J-Camper 

That seems to work beautifully, Many Thanks!

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
0 Likes