Skip to content
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

New Apis #411

Closed
wants to merge 49 commits into from
Closed

New Apis #411

wants to merge 49 commits into from

Conversation

D4ve-R
Copy link
Contributor

@D4ve-R D4ve-R commented Jun 4, 2023

Added

  • ModelApi highlevel model api, accessible in ifcApi.modelApi
  • GeomApi highlevel geometry api, accessible in ifcApi.geomApi

Changes:

  • CreateModel does NOT write ifc headers anymore.
  • multi-line writing,WriteLine accepts Type | Type[] now and returns number | number[]

Example

The following file was written with the new api, see ModelApi & GeomApi tests
Bildschirmfoto 2023-06-04 um 18 29 05

@@ -45,6 +45,7 @@ describe('Test the column example', () => {
count++;
})
expect(count).toEqual(36);
expect(ifcAPI.GetAndClearErrors(m2).size()).toEqual(1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beachtom i suspect the parsing error was that no IfcProject entity is in the model, can you confirm ?

@D4ve-R
Copy link
Contributor Author

D4ve-R commented Jun 6, 2023

@beachtom, you are right, everything was already there it just needed some tweaking.
The new generated classes in ifc-schema are now more usable.
You don't have to pass a expressID as first argument when creating an entity with ne
e.g const app = IFC4X3.IfcApplication({...}, {...}, ...) ,
if you want to set the expressId, you can pass it as the last parameter to the constructor.
Also optional properties of ifc entity are properly translated to ts.

Couldn't find your comments, sorry, can you point me to them ?

@beachtom
Copy link
Collaborator

beachtom commented Jun 6, 2023

Not sure if you saw them all - the main one is for me spinning the package.json commands into shell scripts created a cross platform issue - I built on mac M1 - and I am unsure how it will respond on windows. A quick google implied to me using scripts was not a best practice approach for cross platform.

The other issue is we now have two Dockerfiles in the repo - can we make it so there is only one?

I will need to look at your latest changes later - but thanks in advance

@beachtom
Copy link
Collaborator

beachtom commented Jun 6, 2023

So I like the changes. Good spot on removing the IDs in the schema file to reduce size (I assume that is the reason).

My only thoughts now are: can we have something in the schema gen. Perhaps in schema_aliases (we could perhaps rename that file schema_config) that list objects used in the API

This could then generate for each of them a typescript alias i.e.

type IfcOwnerHistory = IFC2X3.IfcOwnerHistory | IFC4.IfcOwnerHistory | IFC4X3.IfcOwnerHistory

@D4ve-R
Copy link
Contributor Author

D4ve-R commented Jun 6, 2023

Oops, my bad, i didn't intent on pushing the changes in package.json & the build_scripts.
I will check on the docker container, should be possible!

I think a huge benefit of removing the ID is that users don't need to care about them anymore, when creating new objects (they really shouldn't in most use-cases).
As you might have seen, i also removed a lot of special chars from the code generation, resulting in 1MB less data with still good readability.

type IfcOwnerHistory = IFC2X3.IfcOwnerHistory | IFC4.IfcOwnerHistory | IFC4X3.IfcOwnerHistory

that was on my mind too! helps a lot with writing schema generic code

@beachtom
Copy link
Collaborator

beachtom commented Jun 6, 2023

Great - thanks for removing that. I think this will be great once we can merge it.

A few other things I noticed:

  • Commented out grid placement in geom api?
  • Commented out IFCSIUNIT in model API
    -The columns test is failing I suspect ( but am not certain) the writing out there needs to be converted to use the new model API?
    -Thus the columns are also broken in the viewer
    -Examples/usage/src/modification.ts also seems to now be broken

I think most of these are caused by the fact the CreateModel no longer creates the header. I think this is quite a breaking change and may cause a few people lots of issues. Perahps we should add a boolean parameter here that is default to true to outputs the header - and the ModelAPI can set this to false.

Happy to discuss alternative approaches as well

@D4ve-R
Copy link
Contributor Author

D4ve-R commented Jun 9, 2023

I will mark this as a real pull request, as soon as i'm ready to merge.

The columns test should work now, but i haven't tested the viewer examples. When i reopen the generated columns model i get parsing errors. Are you sure that the code generates valid ifc ? Because if yes, that means there might be a bug somewhere.

No all writing is still valid, there is no change in the api.

I also fixed the parsing error for empty sets and changed some test case, because they weren't working as expected.

@beachtom
Copy link
Collaborator

Sorry I mean to reply to this - I will keep an eye out for you to mark it - but if I don't respind just @ me

@beachtom
Copy link
Collaborator

@D4ve-R - I need some of the code from this to be merged to help fixing a bug - do you mind if I extract elements of this and get it merged and you can finish the rest?

@beachtom
Copy link
Collaborator

To grab the code I needed to merge I rebased this to main

@D4ve-R
Copy link
Contributor Author

D4ve-R commented Jul 2, 2023

@beachtom no problem!

@beachtom beachtom closed this Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants