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: 

Add a IFC_GUID BuiltInParameter To a Beam that doesn't contain such parameter

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Anonymous
773 Views, 6 Replies

Add a IFC_GUID BuiltInParameter To a Beam that doesn't contain such parameter

I've created a beam by

   FamilyInstance instance = document.Create.NewFamilyInstance(beamLine, famSymbol, level, StructuralType.Beam);

Now I need to set a particular IFC_GUID value to this element (it comes from another application), but

   Parameter ifcParam = instance.get_Parameter(BuiltInParameter.IFC_GUID);

returns null.

How can I add this parameter? (Some other Elements in the same document have this parameter)

Tags (1)
6 REPLIES 6
Message 2 of 7
jeremytammik
in reply to: Anonymous

I do not believe you can add a built-in parameter to an element that does not have it already.

 

Have the elements on which you see this parameter been generated by the Revit IFC import or link functionality? Are they DirectShape elements?

 



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

Message 3 of 7
Anonymous
in reply to: jeremytammik

I’ve found it! The solution is:

ElementId eid = new
ElementId(BuiltInParameter.IFC_GUID);


Autodesk.Revit.DB.IFC.ExporterIFCUtils.AddValueString(instance, eid,
ifcguid);



The issue I want to solve with this question is:

When Revit imports a beam from a IFC file, the StructuralType of the Element
(or FamilyInstance) is StructuralType.NonStructural, instead of
StructuralType.Beam. So, you can’t assign it any Family / Symbol of
BuiltInCategory.OST_StructuralFraming (nor via API, neither with Revit
menu). So, I must delete the element and create a new one with the correct
StructuralType.Beam and the same IFC_GUID.

Note that this issue doesn’t arise with Structural Columns.


Message 4 of 7
jeremytammik
in reply to: Anonymous

Congratulations on solving your problem!

  

So, the beam does in fact contain the parameter after all, and you just could not see it, because you were passing in the wrong argument type?

 

That makes sense.

 

Thank you for letting us know.

 

Best regards,

 

Jeremy

 



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

Message 5 of 7
Anonymous
in reply to: jeremytammik

No, Jeremy: If you create a new beam with the API, the Parameters propierty of the beam doesn't contain a IFC_GUID member, and get_Parameter(BuiltInParameter.IFC_GUID) returns null.

Only after ussing

   ElementId eid = new ElementId(BuiltInParameter.IFC_GUID);
   Autodesk.Revit.DB.IFC.ExporterIFCUtils.AddValueString(instance, eid, ifcguid);

the method get_Parameter(BuiltInParameter.IFC_GUID) returns correctly and Revit shows it in Porpierties pane.

But, can you tell me how can I change the StructuralType property of an Element from NonStructural to Beam?

Message 6 of 7
jeremytammik
in reply to: Anonymous

Oh, I see. Thank you for clarifying.

 

I did not know (or believe!) that you can add a new built-in parameter to an element.

 

So that functionality is rather special.

  

Unfortunately, the StructuralType property is read-only, so you cannot change it:

 

https://www.revitapidocs.com/2020/6b76b6e9-b334-bae7-bd74-02273f6db108.htm

 

I guess the only way to define it is during creation.

 

So you are doing the right thing creating new beams.

 

 

 



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

Message 7 of 7
jeremytammik
in reply to: Anonymous

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

Post to forums  

Autodesk Customer Advisory Groups


Rail Community