I'm trying to make a bunch of wall openings Top Constraint = Unconnected
I can change the levels for [base constraint] en [top constraint] to another level, but i can't get the [Top Constraint] to be [Unconnected].
This is what I tried: (vb.net)
(MyOpening is already the right element out of MyElementCollector.OfCategory(BuiltInCategory.OST_SWallRectOpening))
Dim MyListOfParameter As List(Of Parameter) = (From MyParameter As Parameter In MyOpening.Parameters).ToList()
Dim MyParameterTopConstraint As Parameter = MyListOfParameter.First(Function(p) p.Definition.Name = "Top Constraint")
MyParameterTopConstraint.Set("Unconnected")
MyParameterTopConstraint.SetValueString("Unconnected")
MyParameterTopConstraint.Dispose()
MyParameterTopConstraint.Set(-1)
When I read the elementId out of the parameter when is is set to 'Unconnected', it returns -1
but setting it to -1 does not work.
please help.
Thanks,
Chris Hanschen
LKSVDD Architecten, Hengelo, Netherlands
p.s.
Somebody builded a Revit model of an existing building, i need to use the model, but is has over 1000 rectangular wall openings
i am making an addin to manage all aspects of these element, such al base offset, height, levels, etc.
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
Have you tried setting it to ElementId.InvalidElementId
?
That has the numerical value -1, but VB is sometimes less than clever and maybe messes it up somehow?
Cheers,
Jeremy
Yes!
That works great!
Thanks a lot!
Chris Hanschen
LKSVDD Architecten Hengelo, The Netherlands
Hi Jeremy,
I think this is not a VB phenomenon.
The parameter's value type is ElementId, so parameter.Set(-1) is of course not the same as parameter.Set(new ElementId(-1)).
Cheers,
Rudi
if was solved by using:
MyParameterTopConstraint.Set(ElementId.InvalidElementId)
so acualy, it should be the same as:
MyParameterTopConstraint.Set(-1)
right?
(but only MyParameterTopConstraint.Set(ElementId.InvalidElementId) works)
Chris
Hi,
no, it's not the same.
parameter.Set(new ElementId(-1)) means setting the parameter by an ElementId object, parameter.Set(-1) means setting it by an integer.
Obviously, your parameter is of ElementId value type, so Set(-1) will never work in this case.
ElementId.InvalidElementId is the equivalent to new ElementId(-1), so both will do the job.
Revitalizer
Oke, I understand.
Thanks a lot for all your posts!
Chris Hanschen
LKSVDD Architecten Hengelo, Netherlands
Hello!
Please, help me find error in my code in variable declaration
Dim MyOpening = col.OfCategory(BuiltInCategory.OST_SWallRectOpening)
Dim MyListOfParameter As List(Of Parameter) = (From MyParameter As Parameter In MyOpening.Parameters).ToList()
or give me correct code to unconnect wall.
Dear Andrew,
From the look of your code snippet, I would suggest that you start by working through the Revit API getting started material and explore the basics of how to set up and use a filtered element collector:
http://thebuildingcoder.typepad.com/blog/about-the-author.html#2
Cheers,
Jeremy
Dear Jeremy!
Unfortunately I have not match time for release my project. Please help my with code to set wall constraint unconnected.
Thank you.
Thank you for your appreciation. Glad to hear it helped.
hi @c_hanschen! can you provide some insight on how you were able to change the Top Constraint level?
I am having trouble with this right now. Top Constraint ElementId is tied to the Level's ElementId. I was not able to simply change the string value of Top Constraint to "Up to level: LEVEL 2" to get this to work.
Thanks!
Hello @pylinet ,
You have to set the new Level by ElementID.
So get the ElementId of the Level by Using MyLevel.ID
.Set (MyLevel.ID)
Get the Level from other Element properties of find it by looping all Levels an find the right Level by Name.
good luck!
Chris Hanschen
LKSVDD architecten
The Netherlands
Skip the .IntegerValue
Just set the ElementId
You need to set the object, not the .IntegerValue