Wall opening make 'Top Constraint= 'Unconnected'

Wall opening make 'Top Constraint= 'Unconnected'

c_hanschen
Advocate Advocate
3,634 Views
16 Replies
Message 1 of 17

Wall opening make 'Top Constraint= 'Unconnected'

c_hanschen
Advocate
Advocate

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.

0 Likes
Accepted solutions (1)
3,635 Views
16 Replies
Replies (16)
Message 2 of 17

jeremytammik
Autodesk
Autodesk
Accepted 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



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 17

c_hanschen
Advocate
Advocate

Yes!

 

That works great!

 

Thanks a lot!

 

Chris Hanschen

LKSVDD Architecten Hengelo, The Netherlands

0 Likes
Message 4 of 17

Revitalizer
Advisor
Advisor

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




Rudolf Honke
Software Developer
Mensch und Maschine





Message 5 of 17

c_hanschen
Advocate
Advocate

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

0 Likes
Message 6 of 17

Revitalizer
Advisor
Advisor

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




Rudolf Honke
Software Developer
Mensch und Maschine





Message 7 of 17

c_hanschen
Advocate
Advocate

Oke, I understand.

 

Thanks a lot for all your posts!

 

Chris Hanschen

LKSVDD Architecten Hengelo, Netherlands

0 Likes
Message 8 of 17

AndrewButenko
Advocate
Advocate

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.

0 Likes
Message 9 of 17

jeremytammik
Autodesk
Autodesk

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



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 10 of 17

AndrewButenko
Advocate
Advocate

Dear Jeremy!

 

 Unfortunately I have not match time for release my project. Please help my with code to set wall constraint unconnected.

Thank you.

0 Likes
Message 12 of 17

AndrewButenko
Advocate
Advocate

Thank you! All is working! Smiley Very Happy

0 Likes
Message 13 of 17

jeremytammik
Autodesk
Autodesk

Thank you for your appreciation. Glad to hear it helped.



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 14 of 17

pylinet
Observer
Observer

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!

0 Likes
Message 15 of 17

c_hanschen
Advocate
Advocate

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

 

 

 

 

0 Likes
Message 16 of 17

pylinet
Observer
Observer
 
I do have access to Level Ids. The issue I am having is I cannot seem to set the value to any Level Id other than -1, which is "Unconnected". The code works if I use .InvalidElementId, but when I try switching it to .IntegerValue, which would allow me to input the LevelId as an integer, it won't work. Interestingly enough, it actually doesn't return an error at all.
 
See code below:
 
def set_param(elementParameterNameValue)
    param_constraint = wall.parameters[ParameterName].Set(elementid.InvalidElementId)
# If I use Set(elementid.IntegerValue) instead, it will not work.

 

t.Start()

 

for wall in wall_elements:
    set_param(wall, "Top Constraint", -1)

 

t.Commit()
 
 
Let me know if you could provide additional insight on this!
 
Thank you!
0 Likes
Message 17 of 17

c_hanschen
Advocate
Advocate

Skip the   .IntegerValue  

Just set the ElementId

 

You need to set the object, not the .IntegerValue

0 Likes