Delete all User Parameters in part or assembly

Delete all User Parameters in part or assembly

Anonymous
Not applicable
933 Views
2 Replies
Message 1 of 3

Delete all User Parameters in part or assembly

Anonymous
Not applicable

Hey,

 

I'm making a data card for Inventor. Now I want 2 tabs in this card, one part and the other assembly.

Both of these have their own user parameters.

These parameters are added with a button in a form.

But when you use the wrong button, the wrong user parameters come in Inventor.

Now I want to be able to remove them all with 1 push of a button.

I also searched the internet for rules but unfortunately couldn't find anything.

Does anyone  have this rule?

0 Likes
934 Views
2 Replies
Replies (2)
Message 2 of 3

Sergio.D.Suárez
Mentor
Mentor

Hi, for a part file I think this rule could help you

 

Dim doc = ThisDoc.Document
For Each oParam As Parameter In doc.componentdefinition.Parameters.UserParameters
	on error resume next
	oParam.Delete
Next

for an assembly file this rule could serve you.

 

Dim openDoc As Document = ThisDoc.Document
For Each doc As Document In openDoc.AllReferencedDocuments
	For Each oParam As Parameter In doc.componentdefinition.Parameters.UserParameters
		On Error Resume Next
		oParam.Delete
	Next
Next

 However, keep in mind that you can not delete a parameter in use, for example a parameter that is using a dimension could not be removed without previously having been removed from the formula of the dimension. For this reason, place the "on error resume next" in the rule so that the parameter that can not be deleted is skipped and continue with the code. I hope it is useful for you. regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 3 of 3

pl.sivakumar
Advocate
Advocate

Part code working good, Thanks for sharing

But Assembly code not working properly

0 Likes