Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Wall opening make 'Top Constraint= 'Unconnected'

16 REPLIES 16
SOLVED
Reply
Message 1 of 17
c_hanschen
2053 Views, 16 Replies

Wall opening make 'Top Constraint= 'Unconnected'

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.

16 REPLIES 16
Message 2 of 17
jeremytammik
in reply to: c_hanschen

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
in reply to: jeremytammik

Yes!

 

That works great!

 

Thanks a lot!

 

Chris Hanschen

LKSVDD Architecten Hengelo, The Netherlands

Message 4 of 17
Revitalizer
in reply to: jeremytammik

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
in reply to: Revitalizer

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

Message 6 of 17
Revitalizer
in reply to: c_hanschen

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
in reply to: Revitalizer

Oke, I understand.

 

Thanks a lot for all your posts!

 

Chris Hanschen

LKSVDD Architecten Hengelo, Netherlands

Message 8 of 17
AndrewButenko
in reply to: c_hanschen

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.

Message 9 of 17

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

Message 10 of 17

Dear Jeremy!

 

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

Thank you.

Message 12 of 17

Thank you! All is working! Smiley Very Happy

Message 13 of 17

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



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

Message 14 of 17
pylinet
in reply to: c_hanschen

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!

Message 15 of 17
c_hanschen
in reply to: pylinet

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

 

 

 

 

Message 16 of 17
pylinet
in reply to: c_hanschen

 
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!
Message 17 of 17
c_hanschen
in reply to: pylinet

Skip the   .IntegerValue  

Just set the ElementId

 

You need to set the object, not the .IntegerValue

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community