common psets

This forum section is only for IFC-related issues
User avatar
bernd
Posts: 8329
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

common psets

Postby bernd » Tue Apr 30, 2019 6:14 am

is it possible to set and export the common psets for ifc 2x3 from within FreeCAD by python? See http://www.buildingsmart-tech.org/ifc/I ... Common.xml for a slab for example.
User avatar
bernd
Posts: 8329
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: common psets

Postby bernd » Tue Apr 30, 2019 6:33 am

found it for the GUI, double click on the object and than in th task panel there is a button. Has someone added properties or Poperty sets by Python?
User avatar
yorik
Site Admin
Posts: 11510
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: common psets

Postby yorik » Tue Apr 30, 2019 2:19 pm

Indeed I'm afraid all the functionality to add IFC properties and property sets is pretty much messily mixed to the UI code :oops: (ArchComponent.py, L1275 basically). This should be separated. Adding this to my TODO list.

But basically it works like this: Each Arch object has an IfcProperties property, which is a string:string dictionary which contains "PropertyName":"PropertySetName;;PropertyType;;PropertyValue" entries (I'm in the process of switching that to "PropertyName;;PropertySetName":"PropertyType;;PropertyValue" because there can be several properties with same name in different psets)

So you can easily add properties manually.

You can get a list of standard property sets with the properties in each with:

Code: Select all

psetdefs = {}
psetspath = os.path.join(FreeCAD.getResourceDir(),"Mod","Arch","Presets","pset_definitions.csv")
if os.path.exists(psetspath):
    with open(psetspath, "r") as csvfile:
        reader = csv.reader(csvfile, delimiter=';')
        for row in reader:
            psetdefs[row[0]] = row[1:]
User avatar
bernd
Posts: 8329
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: common psets

Postby bernd » Tue Apr 30, 2019 2:34 pm

so many to dos ... same problem here ...

great thanks Yorik. This will do the trick for my script, hopefully 8-) . Will try tonight.
User avatar
bernd
Posts: 8329
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: common psets

Postby bernd » Tue Apr 30, 2019 4:04 pm

needed to push a Py3 fix first to get it working git commit a733dc6
User avatar
bernd
Posts: 8329
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: common psets

Postby bernd » Tue Apr 30, 2019 4:05 pm

taking 0.19 for my course is surely good for FreeCAD but not for my sleeping time this week ... :mrgreen: :o :shock:
User avatar
bernd
Posts: 8329
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: common psets

Postby bernd » Tue Apr 30, 2019 7:53 pm

Actually it is quite easy to add properties as long as one does not would like to add standard ifc properties like Common psets, because than it starts to get boring and cumbersome because you need to search in the list manually. We should implement some method to add the Common set. I may have a look.

BTW: the dictionary format is a bit cumbersome (But far much better than what I have been using on my own property import. I may switch to this one). I remember some posts about an own FreeCAD property for ifc properties and property sets implemented in C++ ... How about this one?

bernd
User avatar
yorik
Site Admin
Posts: 11510
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: common psets

Postby yorik » Thu May 02, 2019 7:48 pm

In fact, the whole idea of these common psets is highly cumberstone... If you have 1000 objects in your file, you'll end up with 10000 or 20000 properties, most of them empty and not used. And what if a new version of IFC adds new properties to a common pset? What if you add non-standard properties an a common pset? What if you have incomplete psets? All things that are not clear at all in the ifc docs...

Maybe we should treat these psets differently than other properties, maybe they should be treated as if they were one property with multiple values... Not sure about that...

The property set implemented in c++ in freecad I more or less abandoned it... It was very complicated, needed a lot of UI work, and, above all, it would be of no real use, because freecad has only a small subset of all the available property types in ifc. So in any case it would be of no use for ifc. So for now I used a very hackish way - "propertyName;;psetName":"propertyType;;propertyValue", which at some point should be ported to json, which is the proper and powerful way to pack very complex data structure in strings. And then our PropertyMap will be totally sufficient..