8000 Wrap BrxBim classes · Issue #90 · CEXT-Dan/PyRx · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Wrap BrxBim classes #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
CEXT-Dan opened this issue Jul 7, 2024 · 46 comments
Open

Wrap BrxBim classes #90

CEXT-Dan opened this issue Jul 7, 2024 · 46 comments
Assignees
Labels
enhancement New feature or request

Comments

@CEXT-Dan
Copy link
Owner
CEXT-Dan commented Jul 7, 2024

@CEXT-Dan hope you're well. Could use functionality to import 1) IFC, 2) classify entities (for example by layer name) and 3) export to IFC. I believe it's all BCAD verticals. I am aware that there may be other priorities. Whenever you find the time I would be grateful to be able to script anything.

  1. https://help.bricsys.com/en-us/document/command-reference/i/import-command?version=V24&id=165079082118
  2. https://help.bricsys.com/en-us/document/bricscad-bim/building-data/bim-classify?version=V24&id=165079158884
  3. https://help.bricsys.com/en-us/document/command-reference/i/ifcexport-command?version=V24&id=165079081611

Have in mind that you're about to travel for longer. Wish you safe journey.

Originally posted by @schoeller in #5 (comment)

@CEXT-Dan CEXT-Dan self-assigned this Jul 7, 2024
@CEXT-Dan CEXT-Dan added the enhancement New feature or request label Jul 7, 2024
@CEXT-Dan
Copy link
Owner Author
CEXT-Dan commented Jul 7, 2024

In progress, est two-three weeks

@schoeller
Copy link
Contributor

Saw that you're back online. Hope you're well. Please signal whenever I becomes reasonable to attempt scripting BRX24.2.03.0\samples\brxBimSample\BimIfcImport.cpp

@CEXT-Dan
Copy link
Owner Author
CEXT-Dan commented Sep 3, 2024

I’m going to defer this until V25 is released, reason is, there appears API changes between beta versions. I find myself having to redo stuff.

@CEXT-Dan
Copy link
Owner Author
CEXT-Dan commented Sep 5, 2024

Saw that you're back online. Hope you're well. Please signal whenever I becomes reasonable to attempt scripting BRX24.2.03.0\samples\brxBimSample\BimIfcImport.cpp

Hi, do you have any sample data I can use to test? I'll try to push hard on this next week. Admittedly, this wrap is hard for me, I've never worked with BIM.

@schoeller
Copy link
Contributor

Saw that you're back online. Hope you're well. Please signal whenever I becomes reasonable to attempt scripting BRX24.2.03.0\samples\brxBimSample\BimIfcImport.cpp

Hi, do you have any sample data I can use to test? I'll try to push hard on this next week. Admittedly, this wrap is hard for me, I've never worked with BIM.

Hi as well. I just tried sample data from BuildingSMART. Works as manual import into v24. Hope distraction from vanilla work does not cause too many headaches.

From my current understanding the BCAD BIM (in this case) consists of two parts:

1#Import of geometries into ACIS objects from IFC 2x3 up to 4.1.
grafik

2#Classification of existing objects through a defined tag-catalogue.
grafik

In a current project it would be a time-saver to mass-convert incoming IFC-files to DWG to assemble a collision model (1#). Second goal would be to sync object classification <-> layer structure.

Best wishes.

Seb

@schoeller
Copy link
Contributor

@CEXT-Dan I saw the code snipped from your work. I have tried to load it with the file path correctly set. It messages as follows:

onIfcProduct 94257
<PyBrxBim.IfcImportContext object at 0x00000000030F1F40> False
True

I do not see any objects imported though. I cannot get around figuring out the usage of Bim.IfcImportReactor. Is it already possible to sideload (convert) an IFC to DWG and how would I do that? Best Seb

@CEXT-Dan
Copy link
Owner Author

Hi, it's not ready yet.

@CEXT-Dan
Copy link
Owner Author

I can import the sample from building smart on a local compile. However, I’m having trouble in that onIfcProductImported is never called. It’s not called in the BRX sample either. onIfcProduct is called, however, matrix = context.getLocalPlacement(entity) always returns an identity, This is also the same with the BRX sample.
I’m not sure if this is by design or if BRX has issues. I’ll work this week on filling in the gaps for importing, I expect there will be issues

@CEXT-Dan
Copy link
Owner Author

SR 184312 asks for help

@schoeller
Copy link
Contributor

I can import the sample from building smart on a local compile. However, I’m having trouble in that onIfcProductImported is never called. It’s not called in the BRX sample either. onIfcProduct is called, however, matrix = context.getLocalPlacement(entity) always returns an identity, This is also the same with the BRX sample. I’m not sure if this is by design or if BRX has issues. I’ll work this week on filling in the gaps for importing, I expect there will be issues

I have seen the following in the SDK as well as samples\brxBimSample\BimIfcImport.cpp. Everything else is out of my league

grafik

@CEXT-Dan
Copy link
Owner Author

I had set new guid in
https://github.com/CEXT-Dan/PyRx/blob/main/PySamples/PyBrxBim/importTest.py

onStart, onIfcProduct, and beforeCompletion are called correctly. My guess is that onIfcProductImported has lost its “virtual” status due to some internal change. I still have lots of work on other items in BIM while I wait on the SR… I’ll make a release Thursday as a progress build

@schoeller
Copy link
Contributor

I had set new guid in https://github.com/CEXT-Dan/PyRx/blob/main/PySamples/PyBrxBim/importTest.py

onStart, onIfcProduct, and beforeCompletion are called correctly. My guess is that onIfcProductImported has lost its “virtual” status due to some internal change. I still have lots of work on other items in BIM while I wait on the SR… I’ll make a release Thursday as a progress build

Sorry to have bothered you with this workload.

@schoeller
Copy link
Contributor

Is it somehow possible to fetch properties from Mechanical info (1#) (for example through dump functionality) and copy it into a custom BIM properties set (2#)?
Just curious to save us tons of hours.

1#

2#

@CEXT-Dan
Copy link
Owner Author

Not sure about that off the top of my head
I noticed the mechanical sample that has access to properties. I know Bricsys has a cool properties class for vanilla BricsCAD, I have not wrapped either yet

@schoeller
Copy link
Contributor

Not sure about that off the top of my head I noticed the mechanical sample that has access to properties. I know Bricsys has a cool properties class for vanilla BricsCAD, I have not wrapped either yet

@CEXT-Dan: Thx for the feedback. We will try ourselves with LISP standard tools for the mo. Best of health.

@CEXT-Dan
Copy link
Owner Author

Bricsys was able to reproduce the import reactor issue, I don’t think they will be working on a V24 fix, since V25 is just around the corner. I’ll continue working on Bim wrappers, albeit with a lower priority

@CEXT-Dan CEXT-Dan removed their assignment Nov 7, 2024
@CEXT-Dan
Copy link
Owner Author
CEXT-Dan commented Nov 7, 2024

Seems Bricsys does not want to support me on this project. Closing until something changes

@CEXT-Dan CEXT-Dan closed this as completed Nov 7, 2024
@CEXT-Dan CEXT-Dan closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2024
@schoeller
Copy link
Contributor

Advise is requested:

import traceback
from pyrx_imp import Rx, Ge, Gs, Gi, Db, Ap, Ed, Bim

import wx
import os, pathlib

def openIfcSideDrawing(path, opts):
    print("\nProcessing {} ".format(path))
    db = Db.Database(False, True)
    Bim.IfcImportOptions.importIfcFile(db, path, opts)
    path = str(path[:-3]) + "dwg"
    print(path)
    db.saveAs("c://temp/test.dwg")
    db.closeInput(True)
            
def PyRxCmd_doit1():
    try:
        ifcext = ".ifc".casefold()
        opts = Bim.IfcImportOptions()

        dlg = wx.DirDialog(None, "Choose input directory","",
                wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST)
    
        if dlg.ShowModal() != wx.ID_OK:
            print("You Cancelled The Dialog!")
            return

        for fname in next(os.walk(dlg.GetPath()), (None, None, []))[2]:
            ext = pathlib.Path(fname).suffix.casefold()
            if ext != ifcext:
                continue
            fpath = '{}\\{}'.format(dlg.GetPath(),fname)
            print(fpath)
            openIfcSideDrawing(fpath, opts)
    except Exception as err:
        traceback.print_exception(err)

leads to

Processing C:\Users\Sebastian Schoeller\Downloads\Ifc\13-02_40-00_IWP.ifc 
C:\Users\Sebastian Schoeller\Downloads\Ifc\13-02_40-00_IWP.dwg
Traceback (most recent call last):
  File "C:\Users\Sebastian Schoeller\Nextcloud\10000-Beruf\02-Software\PyRx\ConvertIfc.py", line 34, in PyRxCmd_doit1
    openIfcSideDrawing(fpath, opts)
  File "C:\Users\Sebastian Schoeller\Nextcloud\10000-Beruf\02-Software\PyRx\ConvertIfc.py", line 13, in openIfcSideDrawing
    db.saveAs("c://temp/test.dwg")
PyDb.ErrorStatusException: Exception!(eFileAccessErr), function saveAs1, Line 2150, File PyDbDatabase.cpp:

@CEXT-Dan
Copy link
Owner Author

this works for me, see my comment
also, make sure c:/temp/test.dwg is not opened already

import traceback
from pyrx_imp import Rx, Ge, Gs, Gi, Db, Ap, Ed, Bim

import wx
import os, pathlib

def openIfcSideDrawing(path, opts):
    print("\nProcessing {} ".format(path))
    
    # the ctor is going to change because in this case you are creating 
    # a new drawing which also needs a new document 
    db = Db.Database(True, False) 
    Bim.IfcImportOptions.importIfcFile(db, path, opts)
    path = str(path[:-3]) + "dwg"
    print(path)
    db.saveAs("c:/temp/test.dwg")
    #not needed, this is for reading exisiting drawings
    #db.closeInput(True)
            
def PyRxCmd_doit1():
    try:
        ifcext = ".ifc".casefold()
        opts = Bim.IfcImportOptions()

        dlg = wx.DirDialog(None, "Choose input directory","",
                wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST)
    
        if dlg.ShowModal() != wx.ID_OK:
            print("You Cancelled The Dialog!")
            return

        for fname in next(os.walk(dlg.GetPath()), (None, None, []))[2]:
            ext = pathlib.Path(fname).suffix.casefold()
            if ext != ifcext:
                continue
            fpath = '{}\\{}'.format(dlg.GetPath(),fname)
            print(fpath)
            openIfcSideDrawing(fpath, opts)
    except Exception as err:
        traceback.print_exception(err)

db

@CEXT-Dan
Copy link
Owner Author

oh! also db.saveAs("c:/temp/test.dwg") is in a loop, so if you have more than one .ICF file if will fail because c:/temp/test.dwg is already there

@schoeller
Copy link
Contributor

Thx. Blindfolded. This works for me now:

def openSaveIfcSideDrawing(path, opts):
    print("\nProcessing {} ".format(path))
    db = Db.Database(True, False)
    Bim.IfcImportOptions.importIfcFile(db, path, opts)
    path = str(path[:-3]) + "dwg"
    db.saveAs(path)
    print("\nSaved to {} ".format(path))
    db.closeInput(True)

@CEXT-Dan
Copy link
Owner Author

I’m not sure what to do with this task. The import reactor, (which seems like the most important feature? ) does not work in V24 or V25. I think the class layout is mostly done. I’ll reopen this so it can be worked on.
Maybe there’s some other important features, I don’t really understand BIM

@CEXT-Dan CEXT-Dan reopened this Nov 21, 2024
@schoeller
Copy link
Contributor

Started test scripting the sample from BRX25.1.05.0\samples\brxBimSample\BimClassification.cpp. Noticed that Bim.BimStory.setDescription was non-existant. Compared BRX25.1.05.0\inc\BrxSpecific\bim\BuildingElements.h to PyBrxBimObject.h and have openend a pull request for what I thought to be useful with focus on BimStory.

When doing

ourBuilding = Bim.BimBuilding.createNewBuilding(db, "TowerNorth")
ourBuilding.setDescription("the north side tower building")
floor_1 = Bim.BimStory.createNewStory(db, "TowerNorth", "Floor 1")

all nice, but

floor_2 = Bim.BimStory.createStory("second floor", ourBuilding)

throws

    floor_2 = Bim.BimStory.createStory("second floor", ourBuilding)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Boost.Python.ArgumentError: Python argument types in
    BimStory.createStory(str, BimBuilding)
did not match C++ signature:
    createStory(class PyBrxBimStory {lvalue}, class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >, class PyBrxBimBuilding)

@schoeller
Copy link
Contributor

When trying as per SDK

    // assign floors & building to "hull entities"
    AcDbObjectId idBuilding;
    AcDbObjectIdArray idsForBuilding;
    bimRes = ourBuilding.assignedObjects(idsForBuilding, pDb);
    if (idsForBuilding.isEmpty())
    {
        idBuilding = createBoxSolid(100, 35, 20, AcGeVector3d(0,0,10.0), 1);
        bimRes = ourBuilding.assignToEntity(idBuilding);
    }

in the fashion

        db = Db.curDb()
        model = Db.BlockTableRecord(Db.curDb().modelSpaceId(), Db.OpenMode.ForRead)

        ourBuilding = Bim.BimBuilding.createNewBuilding(db, "TowerNorth")
        ourBuilding.setDescription("the north side tower building")

        if not ourBuilding.assignedObjects(db):
            print("creating building elements")
            box =  Db.Solid3d()
            box.createBox(100.0,35.0,20.0) # createBoxSolid(100, 35, 20, AcGeVector3d(0,0,10.0), 1); add vector
            model.upgradeOpen()
            model.appendAcDbEntity(box)
            ourBuilding.assignToEntity(box.id())
            model.downgradeOpen()

I see no properties attached to the solid.

@CEXT-Dan
Copy link
Owner Author

Looks right.

Just to add:
Also everything in IfcExportReactor.h is missing, I stopped because the import reactor seems not to work in BRX

BimPropertySets looks quite hard to wrap

listAllPsetProperties “std::map<AcString, std::map<AcString, std::map<AcString, AcValue>>>:

IMHO the API isn’t well thought out, Bricsys had to alter the API to be more usable from .NET
If you have everything you need, I will work on missing items over the coming weeks

@schoeller
Copy link
Contributor

IMHO the API isn’t well thought out, Bricsys had to alter the API to be more usable from .NET If you have everything you need, I will work on missing items over the coming weeks

I should be very fine. Thanks a ton for letting me participate. Am learning from your coding and corrected contributions.

Copy link
9E88

Stale issue message

@CEXT-Dan
Copy link
Owner Author

bumping this so I don't forget, hoping Bricsys will fix the reactor

@schoeller
Copy link
Contributor

For the record, I have just diff-compared BRX25.2.02.0\inc\BrxSpecific\bim\ versus BRX25.1.05.0\inc\BrxSpecific\bim\ and come to the following conclusions:

  • [-] AnchorFeature.h: cosmetic differences
  • [-] BuildingElements.h: BimElementType is marked as redundant for use of string signatures instead; BrxBimLinearGeometry has new method getEndFaces; some methods in BimClassification have been marked as deprecated; cosmetic differences
  • [-] IfcImportReactor.h: ~BimIfcImportInfo (typo?) has been corrected

Without knowing much about software design etc. I see no need for action. I do not know whether the reaction has been fixed or whether it was due to the typo.

@CEXT-Dan
Copy link
Owner Author
CEXT-Dan commented Mar 9, 2025

Hoping the reactor is fixed. Also some of the BRX functions are not really well thought out, there’s nested dictionaries, too complex, I noticed that the .NET version is a bit cleaner, so I might get inspiration from that.

@CEXT-Dan
Copy link
Owner Author
CEXT-Dan commented Apr 14, 2025

Version 25.2.05 SR194193
The IfcImportReactorInstance::onIfcProductImported() callback was broken in V24. The problem has been fixed, so that it is called again for each imported product.

I'll need to revisit the code

@CEXT-Dan CEXT-Dan self-assigned this Apr 14, 2025
@CEXT-Dan
Copy link
Owner Author

import test seems to work

Success module IMPORTTEST is loaded: 
: DOIT1
onStartCalled True
onProductCalled True
completionCalled True
onIfcProductImportedCalled True

CEXT-Dan added a commit that referenced this issue Apr 14, 2025
@schoeller
Copy link
Contributor

Trying to compile using VS 2022 and am getting subsequent error:

It disappears when doing

//enum class Ice::IfcApi::Result;
namespace Ice {
    namespace IfcApi {
        enum class Result;
    }
}

CEXT-Dan added a commit that referenced this issue May 18, 2025
@schoeller
Copy link
Contributor

I guess I cannot figure out IfcExportReactor.h

@CEXT-Dan
Copy link
Owner Author

I guess I cannot figure out IfcExportReactor.h

Do you mean to wrap it? Or are you having trouble building?

@CEXT-Dan
Copy link
Owner Author

I'll start working on IfcExportReactor, I know you've been waiting for this.

@schoeller
Copy link
Contributor

I'll start working on IfcExportReactor, I know you've been waiting for this.

Thx, but no hustle. The project has been canceled. I looked at the header file this morning and could not get my head around it (sparetime hobbyist). I think it would be useful though to close the import/export loop.

CEXT-Dan added a commit that referenced this issue May 19, 2025
CEXT-Dan added a commit that referenced this issue May 19, 2025
CEXT-Dan added a commit that referenced this issue May 20, 2025
CEXT-Dan added a commit that referenced this issue May 20, 2025
CEXT-Dan added a commit that referenced this issue May 21, 2025
CEXT-Dan added a commit that referenced this issue May 21, 2025
CEXT-Dan added a commit that referenced this issue May 22, 2025
CEXT-Dan added a commit that referenced this issue May 27, 2025
@CEXT-Dan
Copy link
Owner Author

Export reactor seems to work enough to generate a file, though I’m sure there are issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants
0