Converting parameters to Target parameter storage type

Hi everyone,

I am going through the process of copying family parameters from one to the other, but am running into parameter storage type issues. For example, the usual “Parameter storage type in not a string” error comes up in addition to others.
I saw this thread on the forum:


But unfortunately I do not understand Python very well.
Is there a way to convert a parameter (Regardless of what storage type it is) to the target parameters storage type?

Any help would be appreciated!
Thank you!

Hey,

If you search around you will see a few other relevant topics such as this one Copy a number value from one paramter to another

If you are grabbing parameter values from one family and pushing them into another, they should be the correct type already… Perhaps check your list management?

If instead you are grabbing the values from Excel say, you need to grab the parameters from the family, check their type, then convert them.

I guess it would be a good idea to first filter out any parameters which are read only (e.g room areas or those driven by formula)

Without Python I presume you will then run a series of BoolFilters… If Param Type == Int, convert String to Number… Which is fine for a few types… But you might end up with a very long graph…

Hopefully that’s enough to get you started? Post back if you get stuck and we can try to assist :slight_smile:

Cheers,

Mark

Good morning Mark,

Thank you very much for the helpful comments, this is definitely enough to get me started, I will start putting it together today as best I can :slight_smile:

I am trying to map parameters from a 3rd party part to our parts, that is the overall goal i have. If the 3rd party uses the terminology “Diam1” and we use “Diameter”, I need to give the user the ability to say “Diameter” from the our part == “Diam1” from the 3rd party part, then copy the existing formula across from our part to the 3rd party. I’ve actually managed to assemble the code to complete what I have just said, but I have been having trouble accounting for all the potential differences in parameter storage types. Given that it is a 3rd party part, they may have created the “Diam1” as a Length, and our’s might be a string as an example, and this is where all the difficulty is coming into play.
But I will give your thought a go and see if I can get it to work.

Thanks again Mark, appreciate your help!

It sounds complex!

I suspect that a little Python would go a long way for you…

parameters = IN[0] #get the parameters coming in (it's a list)
booleans, number, strings, fail = [],[],[],[] #make some lists for our filtered parameters to go in
for parameter in parameters:
	if 'Int64'in str(type(parameter)) or isinstance (parameter, float): #python struggles with int64!
		number.append(parameter) 
	elif isinstance (parameter, bool):
		booleans.append(parameter)       
	elif isinstance (parameter, basestring):
		strings.append(parameter)
	else:
		fail.append('we do not know what type this is')

OUT = number, booleans, strings, fail

Hope that helps,

Mark

1 Like

HI Mark,

Thank you for this content, I’ll definitely be able to incorporate this into the workflow somewhere.

Thanks again for your help and suggestions :slight_smile:

Have a good one!

1 Like

Just something else that occured to me… zip is very useful when running these kinds of things… though it is worth noting for all this python, list management is totally manual, it won’t handle levels or lacing, so both your lists must be the same length for zip to work.

names = IN[0] #get the parameters coming in (it's a list)
parameters = IN[1]
booleans, number, strings, fail = [],[],[],[] #make some lists for our filtered parameters to go in
for parameter, name in zip(parameters, names):
	if 'Int64'in str(type(parameter)) or isinstance (parameter, float): #python struggles with int64!
		number.append([name, parameter]) 
	elif isinstance (parameter, bool):
		booleans.append([name, parameter])       
	elif isinstance (parameter, basestring):
		strings.append([name, parameter])
	else:
		fail.append([name, parameter, 'we do not know what type this is'])

OUT = number, booleans, strings, fail

Hi Mark,

Great, thanks for this again! I will try to understand what is going on here as my Python is not where it needs to be I feel :slight_smile:
Thanks again for your suggestions and help!

1 Like