-
Notifications
You must be signed in to change notification settings - Fork 35
Implement STEP export #11
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
Conversation
Embedding STEP export capabilities into the generated classes
|
@simonmoreau I saw your tweet about making a PR to one of my repos and I hadn't recognized that this was the one. Perhaps a setting with my notifications :( In any case, I apologize for not having seen this sooner. I'll take a look and get back to. Might take a couple of days with the Holidays here in the US. |
|
@simonmoreau You should know as well that I am merging IFC-dotnet into IFC-gen. Working back and forth between the two repositories was causing unnecessary overhead. So your PR in IFC-dotnet will have to be applied here (or I might do it if the change seems reasonable). I will be making the merge soon and I'll update you with how this relates to your PRs. |
ikeough
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much for this submission @simonmoreau! I've highlighted a number of improvements, mostly syntactical. There will most likely be another round of review when these changes are picked up.
| { | ||
| [JsonProperty(""id"")] | ||
| public Guid Id{get;} | ||
| public Guid Id{get;set;} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was intentionally left without a setter. After an object of type IfcBase is constructed, we do not want this value to be changed. Is there a way that we can set this value without giving it a public setter? Could we make this property wrap a private id field and use one of the STEP reading methods to set that instead?
| throw new NotImplementedException(); | ||
| } | ||
| } | ||
| public virtual string STEPParameters(ref Dictionary<Guid, int> indexDictionnary) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dictionary...spelling aside, I think we could just call this indexMap or simply indices.
src/IFC-gen/csharp/TypeData.cs
Outdated
| string prop = ""; | ||
| if (Type.EndsWith("Enum") | Type == "bool" | Type == "int" | Type == "double") | ||
| { | ||
| prop = $"\t\t\tparameters.Add({Name}.STEPValue(ref indexDictionnary));\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've taken to not adding newlines in formatted strings. Usually, ToSTEPString will be called when calling StringBuilder.AppendLine(...), and adding the newlines explicitly to the string can cause duplication of newlines.
src/IFC-gen/csharp/TypeData.cs
Outdated
| } | ||
| } | ||
|
|
||
| /// <summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happened with TypeData? Was a tab inserted or removed?
| { | ||
| if (indexDictionnary.ContainsKey(Id)) | ||
| { | ||
| return ""#"" + indexDictionnary[Id].ToString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IFC-gen uses new-age c# string replacement. This could be $"return {indexDictionary[Id].ToString()}".
| public virtual string ToSTEP(ref Dictionary<Guid, int> indexDictionnary) | ||
| { | ||
| return string.Format(""{0} = {1}({2});\r\n"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments elsewhere re: newlines and string replacement.
| this.STEPParameters(ref indexDictionnary)); | ||
| } | ||
| public virtual string STEPValue(ref Dictionary<Guid, int> indexDictionnary) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could simplify this method by assuming that the Dictionary<Guid,int> will be maintained outside this method. This would change the signature to STEPValue(int index).
src/IFC-gen/csharp/TypeData.cs
Outdated
| } | ||
| else | ||
| { | ||
| string stepValue = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these can be simplified to just return $@"...".
|
@simonmoreau I've merged the changes which I mentioned above. I apologize that this will add some extra work for you to figure out how to adapt your PR. I'm hoping that these organizational changes to the repo will settle down soon. |
|
@ikeough Thanks for the review ! I will edit my PR and add the IFC-dotnet one in this repo. |
Build in windows
Support for non-US culture
Edit IFC-dotnet-test.csproj to be able to debug test
Add Extension to export simple type to STEP
Implement ToSTEP(Dictionary<Guid, int> indexMap) to convert an IfcBase into its STEP string Implement ToStepValue(Dictionary<Guid, int> indexMap) to convert an Ifc entity into its STEP index, or its STEP value as a string Implement GetStepParameters(Dictionary<Guid, int> indexMap) to get all attributes as either STEP index or STEP value
|
@simonmoreau I haven't forgotten about this. I've made some incompatible changes since your updates and rather than ask to you update this PR yet again, I'm merging your changes manually. Hopefully this will be done soon. |
|
@ikeough I also kept working on it, if you want, I can edit the PR again to integrate these changes |
|
Thanks, but I’m almost there. There was some significant challenges with the STEP writer writing STEP files that were invalid, which I’ve almost ironed out. I should be able to merge this code today. |
|
@simonmoreau I've merged your contributions and my updates to align them with master. Thanks very much for this submission. You will note that I did a couple things to your code:
The STEP export is still broken due to |
|
Great! Thank you for your help! |
This pull request implements export functions in the IFC classes to create an IFC (STEP) file.
It adds the method STEPValue(ref Dictionary<Guid, int> indexDictionnary), which need an indexDictionnary to keep track of the relation between STEP index and Guid. This method gives for each IFC class its corresponding STEP value in the file (whether an index or an inline value).
This pull request follow another pull request in IFC-dotnet