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

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

Anonymous
Not applicable
1,142 Views
6 Replies
Message 1 of 7

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

Anonymous
Not applicable

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)

0 Likes
Accepted solutions (1)
1,143 Views
6 Replies
Replies (6)
Message 2 of 7

jeremytammik
Autodesk
Autodesk

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

0 Likes
Message 3 of 7

Anonymous
Not applicable
Accepted solution
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.


0 Likes
Message 4 of 7

jeremytammik
Autodesk
Autodesk

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

0 Likes
Message 5 of 7

Anonymous
Not applicable

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

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

0 Likes
Message 7 of 7

jeremytammik
Autodesk
Autodesk