PDA

View Full Version : Setting Parameters Programmatically



awhite343
2006-07-11, 05:03 PM
Hey all:

Is it possible to change an object's parameters programmatically? In VB2005, I get an error that the property 'Parameter' is read only when using the following line:

Set elem.Parameter(Parameters.BuiltInParameter.STRUCTURAL_NUMBER_OF_STUDS) = "(24)"

Is there another way to set this that I'm missing or is this not accessible currently through the API?

I'd like to make an improved "match type" command for composite steel beams, but am not sure if it's possible. The "match type" program native to REVIT will only change the beam size, but the other parameters do not carry over (for example, "number of studs" and "camber"). So, I'd like a program that would not only change the beam, but also set the parameters for "number of studs" and "camber". Currently, the user has to manually enter in the number of studs and camber for every beam, either by accessing the object's properties or selecting its tag. This is obviously brutally slow compared to our previous customization in other platforms.

Thanks in advance,
Aaron

GuyR
2006-07-11, 07:18 PM
Try this (in c#)

Parameter Param = elem.get_Parameter(Parameters.BuiltInParameter.STRUCTURAL_NUMBER_OF_STUDS);

Param.Set = 24;

HTH,

Guy

Danny Polkinhorn
2006-07-11, 09:50 PM
Not all of the Built-in parameters are read/write. If you're getting a read-only error, unfortunately that's means it's read-only.

Sorry, I'm not too familiar with the structural API, but is there another read-write parameter which drives this value, which you could change instead?

HTH,

david.bartliff
2006-07-17, 04:31 PM
Did you sort this out because I found the 2 answers misleading.

This parameter is definitely not read only, (unless the elements are locked in a multi-user environment), because our application sets the value but is written in C#. You need to be aware that this is a string, not a numeric parameter, and you need to call the Set method with a string argument. I think this should work in Basic.

Dim studParameter As Parameter = elem.Parameter(Autodesk.Revit.Parameters.BuiltInParameter.STRUCTURAL_NUMBER_OF_STUDS)

studParameter.Set("24")

Danny Polkinhorn
2006-07-17, 07:45 PM
Sorry, wasn't trying to be misleading. If he was passing the wrong parameter type, it wouldn't have given him a read-only error, it would have given an invalid type error.

Looking at your post, it appears he had a syntax error.

HTH,

awhite343
2006-07-18, 12:49 PM
David, Guy, and Danny:

Thanks for all your replies...I tried David's method this morning and it worked like a charm...My syntax was incorrect as Danny notes and that must have been causing the read-only error for some reason...

Sorry for the pedestrian question (I'm switching from VBA in AutoCAD/Excel/Word to VB in RST).

Thanks again,
Aaron