Associate element to level?

Associate element to level?

Anonymous
Not applicable
2,608 Views
10 Replies
Message 1 of 11

Associate element to level?

Anonymous
Not applicable

The LevelId seems to be an read-only and so can not be set through the API.

Does the API allow us to associate an element to a level (generic models and such)?

And if so, how would i be able to do this?

 

0 Likes
2,609 Views
10 Replies
Replies (10)
Message 2 of 11

OR_AND_NO
Advocate
Advocate

I believe the way to set levelid for element in API exists: In order to create element instance You have to set level.

0 Likes
Message 3 of 11

Revitalizer
Advisor
Advisor

Hi,

 

depending on the class and category of your Element, there are different BuiltInParameters to set the level.

 

FamilyInstances - BuiltInParameter.FAMILY_LEVEL_PARAM;
Elements of category:
BuiltInCategory.OST_Walls - BuiltInParameter.WALL_BASE_CONSTRAINT
BuiltInCategory.OST_Roofs - BuiltInParameter.ROOF_BASE_LEVEL_PARAM
BuiltInCategory.OST_Floors - BuiltInParameter.LEVEL_PARAM
BuiltInCategory.OST_Stairs - BuiltInParameter.STAIRS_BASE_LEVEL_PARAM
BuiltInCategory.OST_Rooms - BuiltInParameter.ROOM_LEVEL_ID
BuiltInCategory.OST_Areas - BuiltInParameter.ROOM_LEVEL_ID

 

The parameter may be readonly in some cases.

Also, there may be Families definied without Level association.

 

Note: even setting the according levelId parameter does not set the levelId property in each case.

 

 

Revitalizer

 




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 4 of 11

Revitalizer
Advisor
Advisor

Hi,

 

see also

http://forums.autodesk.com/t5/revit-api/help-get-the-level-id-of-the-element-beam-structural-framing...

 

The post's topic is about getting the level, you may have to try out whether the parameter can be set, too.

 

 

Revtalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 5 of 11

jeremytammik
Autodesk
Autodesk

Dear Dante,

 

Thank you for your query.

 

As already pointed out by Or_and_no and Revtalizer, in general, elements cannot be moved freely from one level to another after they have been created, since that can have hefty consequences for the BIM.

 

In many cases, you can specify the level when the element is being created, e.g., as an argument to the NewFamilyInstance method, but not modify it afterwards.

 

Can you move the elements you are interested in freely between levels in the user interface?

 

If not, in general, the API will not allow this either.

 

I can imagine that there are good reasons why the level cannot be changed after the element creation.

 

Of course, it will also depend heavily on the element type.

 

Still, I have already heard this request several times in the past, so I submitted a wish list item for you, to see what the development team respond:

 

I submitted the wish list item CF-3268 [API wish: set level of element] on your behalf for the functionality you suggest, as this issue requires exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

We will see what they say about this.

 

I hope this helps.

 

Best regards,

 

Jeremy



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

Message 6 of 11

Anonymous
Not applicable

Someting i am really struggeling with:

 

When placing a family (structural framing) the family can be either workplane based or just default level based.

 

When its level based, this seems to be working:

 

FamilyInstance tempFamily = doc.Create.NewFamilyInstance(someCoordiane, familySymbol, someLevel, Autodesk.Revit.DB.Structure.StructuralType.UnknownFraming);

 

Where the Level is found as Level (not using LevelType or LevelTypeSet (should i?))

This seems to be placing the family in the right spot, on the right level.

 

But here is the thing, when i check the checkbox in the family to set it as "Workplane-based" it doesnt want to use the levels anymore resulting in the fact they all get placed on z 0, and getting a grayed out Edit workplane menu. But when i use a SketchPlane as level instead of the actual Level class, it seems to work just fine again.

At first this seems to work, though here is the catch:

It places the family on "Reference plane: MyLevel - 01"  instead of "Level: MyLevel - 01". It actually results in placing it in the right place looking in the 3D model, though in the schedules you can only make it sort on levels, and not reference planes.

 

Is there some way to actually grab the corresponding SketchPlane that belongs to a specific level, so i can place workplane-based family instances on the right sketchplanes corresponding to the specific levels (so my schedule filters/grouping/sorting will work too)

 

 

Message 7 of 11

Revitalizer
Advisor
Advisor

Hi,

 

for use in schedules, there is a BuiltInParameter.SCHEDULE_LEVEL_PARAM in your FamilyInstance.

Don't know if it is readonly.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 8 of 11

jeremytammik
Autodesk
Autodesk

You ask, "Is there some way to actually grab the corresponding SketchPlane that belongs to a specific level?"

 

Level is derived from the DatumPlane base class. I see the Level.GetPlaneReference method. That could be used to retrieve the geometric plane, via the Element.GetGeometryObjectFromReference helper method. I do not see an direct access to the sketch plane, however. You could always iterate over all sketch planes in a filtered element collector and match their geometric planes with the geometric planes retrieved from your candidate level. If there is just one match, that would be the one you want.

 

Cheers,

 

Jeremy



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

0 Likes
Message 9 of 11

Anonymous
Not applicable
0 Likes
Message 10 of 11

c_hanschen
Advocate
Advocate

I have the same problem here!

Your post is from 2015, is there a solution yet?

 

When creating a FamilyInstance with  Autodesk.Revit.Creation.FamilyInstanceCreationData with assigning a Level, the element is not placed at that Level. Even while the FamilyInstance is WorkPlaneBased.

 

Trying to set it after placement Fails, all this Parameters are ReadOnly:  
"Work Plane", BuiltInParameter.FAMILY_LEVEL_PARAM, BuiltInParameter.SCHEDULE_LEVEL_PARAM

 

With all the possibilities Revit API provides (mean it as a compliment!) it must be possible some how......

Is there a solution yet?

 

Thanks,

 

Chris Hanschen

The Netherlands.

 

 

0 Likes
Message 11 of 11

c_hanschen
Advocate
Advocate

When addressing Autodesk.Revit.Creation.FamilyInstanceCreationData with a Host instead of a Level, than the 'Work Plane' get's the Name of the Level.

 

But, the 'Offset' Value is still from Z=0

Why? I don't understand.

The value of the Work Plane gets the Name of the Level, not 'Level : LevelName'.

So now the Work Plane mentions the Name of a Level, but the Offset is from Z=0

 

I don't understand! Somebody can tell me more?

 

Thanks,

 

Chris Hanschen

The Netherlands.

0 Likes