icon

Support Forum

ElementSelectService Problem [Gelöst]

Schlagworte:
  • Allplan
  • 2025
  • PythonParts
  • ElementSelectService

Hi!

First, I would like to say that the framework and its documentation have made great progress!

I have a problem with ElementSelectService. I have a list of Ifcids and corresponding objects in Allplan.

guidlist=[dbel.ifcguid for dbel in ap_dbeles.values()]
ap_adapterlist:AllplanElementAdapter.BaseElementAdapterList=ApBase.ElementsSelectService.SelectElementsByIfcGuid(self.doc,guidlist)
#ap_adapterlist:AllplanElementAdapter.BaseElementAdapterList=ApBase.ElementsSelectService.SelectAllElements(self.doc)
AllplanIFW.HighlightService.HighlightElements(ap_adapterlist)
adp=ap_adapterlist[0]
print("DEBUG BASEELEMENTADAPTER",adp.GetDisplayName(),adp.GetElementAdapterType().GetModelType())

I want to select them with ElementsSelectService.SelectElementsByIfcGuid. It works fine, I use the HighlightService to confirm that the objects are found.
But the BaseElementAdapter items in the list are not what I would expect.

console.log:
DEBUG BASEELEMENTADAPTER Erweitertes Element 2ea36adf-0361-4a38-9555-7c5af3320bf4

I cant do anything with it. It has no geometry, it doesnt have AllplanElements etc.

ElementSelectService.SelectAllElements(self.doc) works as expected, it returns the expected type. Is there an additional step required for selection with Ifcids?
Im using Allplan 2025 1.1+.
Thank you very much,
Best regards

Lösung anzeigen Lösung verbergen

Hello bimbimboris

I never really succeeded to get something with the SelectElementsByIfcGuid, so I am glad you did. But also I can't tell anything from my experience, but I can suggest something:

Have you tried to look up the PARENT or CHILD objects of the returned Erweitertes Element adapter? You can use the logic in this example to print the entire hierarchy. Maybe what you are looking for is the child or parent of the erweitertes element. At least that's something I would try.

Cheers,
Bart

Hello bimbimboris

I never really succeeded to get something with the SelectElementsByIfcGuid, so I am glad you did. But also I can't tell anything from my experience, but I can suggest something:

Have you tried to look up the PARENT or CHILD objects of the returned Erweitertes Element adapter? You can use the logic in this example to print the entire hierarchy. Maybe what you are looking for is the child or parent of the erweitertes element. At least that's something I would try.

Cheers,
Bart

Thank you, you are right with your suggestion.
The Elements are nested as Children of the "Extended Element". Weird, because all the checks you can do on the BaseElementAdapter give no hints.

Here is my code to produce ifcids.

new_uuid=uuid.uuid4()
ifc_guid=base64.b64encode(new_uuid.bytes,b"_$").decode("utf-8")[:-2]

example id :2iuZw2AxRje5eM3JKeQmaw
It`s a valid Id and stays consistent in the ifc file after exporting. Maybe it can help you to reproduce my success with the function.

One more question regarding the function SelectElementsByIfcGuid():
Is there any chance that the function could be changed in a way that it appends None to the resulting list when an element is not found?
e.g. : result=SelectElementsByIfcGuid(doc,guidlist) console:[ele,ele,None,ele,None,None,ele..]

At the moment, I dont see a way to find out which elements are actually found in the model without looping over selection result list, take attributes, check for attribute 683, check if in guid list. This should be more convenient when using SelectElementsByIfcGuid. If the list was ordered in the same way the input list with guids is, + None for not found elements, you could zip them together again without attribute checks.