Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic Rule to Rename Parameter NAMES (not values)

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
bmerton
3545 Views, 8 Replies

iLogic Rule to Rename Parameter NAMES (not values)

I have been trying to create hundreds of features with random sizes and positions on a face.

I want to change their parameter names (not values) using iLogic.

ie

d0262 becomes "Rectangle_Left_1"

The idea is to use a spreadsheet as far as possible. Right now, I have to change each parameter name manually. This takes HOURS!

I can export the existing parameter names but am unable to update them. Any ideas?

Help!!
8 REPLIES 8
Message 2 of 9
rossano_praderi
in reply to: bmerton

Hi, this is a basic example for change the parameter name.

 

Dim oDoc as PartDocument
oDoc = ThisApplication.ActiveDocument
Dim oFeature As PartFeature
For Each oFeature In oDoc.ComponentDefinition.Features
    If oFeature.Name = "iFeature15:1" Then 'Old name
        oFeature.Name = "test" 'New name
    End If
Next

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Tags (2)
Message 3 of 9
bmerton
in reply to: bmerton

Thanks Rossano

What would be the equivalent for parameters rather than iFeatures?

Ben

Message 4 of 9
rossano_praderi
in reply to: bmerton

Hi Ben, yes it is.

I'm wrote "Features" instead of "Parameters", sorry.

 

This the correct code.

 

Dim oDoc as PartDocument
oDoc = ThisApplication.ActiveDocument
Dim oParameter As Parameter
For Each oParameter In oDoc.ComponentDefinition.Parameters
    If oParameter.Name = "d0" Then
        oParameter.Name = "test"
    End If
Next

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Tags (2)
Message 5 of 9

How Can you set a more general search in the name, as in..

oParameter.Name <> "My_Searching_Parameter" then
oParameter.Name = My_Parameter


 



 

Message 6 of 9

Hi, the following code is the simplest solution (converted from my original code)

 

	Sub CheckAndChange(oDoc as PartDocument, oParameter As Parameter, NameToFind as string, NameToAssign as string)
		For Each oParameter In oDoc.ComponentDefinition.Parameters
			If oParameter.Name = nametofind Then
				oParameter.Name = nametoassign
			End If
		Next
	End Sub

If you would like a more complex, but as simple implementation, solution which check a string with given "searching_parameters", the following linked function can give you a basic idea on where you can start.

https://dotnetfiddle.net/YOo5Rf

 

Bregs

Rossano Praderi

 



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 7 of 9

Yes Thanks, But...

I what i meant is since the name to find can be whatever... because i want the same parameter to change between 40 different parameters names, i wont which name it will be currently on.

So to set it to these 40 different names i just wan to check if "its not equal to" to that name then assign it that name.

I cant use the <> operator somehow...

is there another operator to say is not equal to? i tried searching online already...

 

thank you for you prompt response

Message 8 of 9

You should open a new thread and give to the community an example of what you would like to obtain.
Your question can have many solutions and, may be, your first step is not to find the right operator.



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 9 of 9
robmoras
in reply to: bmerton

SyntaxEditor Code Snippet

Parameter.Param("d0").Name="new"

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report