icon

Create Project attributes / Building structure attributes


Hi there,

I am currently trying to automate the creation of a set of attributes to be assigned to the Building structure so that they can be directly connected to the IfcBuilding entity when exporting the model to IFC.

I have created specific attributes using "AllplanBaseEle.AttributeService.AddUserAttribute()" and then try to assign them using "AllplanBaseElements.ProjectAttributeService.ChangeAttributesFromCurrentProject()", but this doesn't seem to work.

The newly created attribute is not listed by the line "AllplanBaseElements.ProjectAttributeService.GetAttributesFromCurrentProject()". Furthermore, when I check the attributes using the GUI, these are not listed under "Building structure attributes".

I am guessing the project attributes and attributes assigned to the Building structure are not the same thing. Nonetheless, I am not seeing another way of getting this done. Please note the short script below.

svc = AllplanBaseEle.AttributeService
vec = AllplanUtil.VecStringList()

new_id = svc.AddUserAttribute(
                    self.document,
                    svc.AttributeType.String,
                    "KUBA_ALG Id Bauwerk_PR",
                    "Empty|Empty",
                    0.0, 0.0, "",
                    svc.AttributeControlType.ComboBoxFixed,
                    vec
                )

TestAtt=[(new_id,"Empty")]
AllplanBaseElements.ProjectAttributeService.ChangeAttributesFromCurrentProject(TestAtt,self.document)

Let me know if there is any particularity about Project attributes that I am missing.

Cheers,

Hi,

  • AllplanBaseEle.AttributeService.AddUserAttribute()
    creates a user element attribute = an attribute, that can be assigned to an element, not to a project
  • AllplanBaseElements.ProjectAttributeService deals with project attributes, not with the building structure attributes
  • I am not 100% sure, but I think project attributes are not assigned to the IfcBuilding entity, but to the entire IfcProject. The latter may contain multiple IfcBuildings
  • API currently does not offer the possibility of assigning the element attributes to the building structure elements

Currently, all you can do is reversed engineering: reading and creating xml files directly.
The building structure itself is defined in

X:\Path\to\your\Prj\BIM\Allplan_BIM_BuildingStructure.xml
From here you can establish the UUID of the building structure element, you want to assign attributes to.
The function AddUserAttribute() returns the ID of the attribute you have to assign.
The attributes of a specific the building structure element are saved in
X:\Path\to\your\Prj\BIM\BwsAttribute_00000000-0000-0000-0000-000000000000.xml
You need to replace the null-UUID with the UUID of the desired building structure element.

I hope this solution is sufficient for your use-case.

Best,
Bart