Open Brent-bai opened 8 months ago
I create a minium environment, only click a command to run above function, they all work well. In my code, first creat a sketch, then click a command to start a poperty manager page, as I click one button of the page to run the first code above, the sw app crashed. It seemes sw crashing when returning to my command page. Then I add the AddHorizontalDimension2() to the third code above, the sw app crashed again. It is highly suspected that a memory access issue occurred when the sketching tool's property manager switched back to my property manager page.
I'm sure it does cause by my pmp closing when sketchtool raising. This command may not use pmp.
There is a constance "OPTS_DEFAULT" in internal Show() which in Internal class PropertyManagerPagePage of Xarial.XCad.SolidWorks.UI.PropertyPage.Toolkit.Controls, it allow the other page to be a StackPage. Make it to a page attribute may resolve this issue.
Yes, that makes sense to add an option to have StackPage. I will add one.
Regarding the sketch. Yes, AddToDB is used: https://github.com/xarial/xcad/blob/!dev/src/SolidWorks/Sketch/SwSketchEntityCollection.cs#L73C2-L89
But if I am not mistaken this was added into the pre-release version (e.g. 8.X and not available in 7.X)
I have changed "OPTS_DEFAULT = 1", it does not worked. The property manager page will not being closed when I click the OK or Cancle button. Here is my sample code: SketchCreateTest.zip
I used lockedPage attribue ([PageOptions(PageOptions_e.LockedPage)]) option to resolve the problem, avoiding the crashing of sw when inserting a point and adding dimension. But unfortunately in this option, the SelectById2 method will not work. Because some sketch points are com_object, it can not use Select4 method to select the point. It seems I have tried all the way, but I can't find the right answer.
This code cause sw app crashing with no reason. I change the code to solidworks api as below:
It also cause the app crashing. The CreatPoint() throw a exception: "This is often an indication that other memory is corrupt.” I ask the ChatGpt, it changed the code to:
I noticed the code adding a SetAddToDB() method, and it worked. I wonder that xcad.net api having considered this issue.