In my code, I create a copy of dimension style:
s3 = New DimStyleTableRecord s3.CopyFrom(vz) s3.Name = nazov tst.Add(s3) _trans.AddNewlyCreatedDBObject(s3, True)
then, in another part of the code, I open the new style and change a property:
Using trans As Transaction = db.TransactionManager.StartTransaction ds = trans.GetObject(ds.ObjectId, OpenMode.ForWrite) ds.Dimtxsty = s2TextStyle.ObjectId trans.Commit() End Using
this works OK for the first time, but when I run the code again, I don't create the new style, I just take the existing one and changing the Dimtxtsty property to the value it already has causes AutoCAD crash
Solved! Go to Solution.
My guess would be that your object was createcd/copied in the context of a different transaction and you don't have access to it the second time around.
It would help if you recreated your problem in a self contained example (autocad command) so that people can try it themselves. For instance I could copy your code into an existing project that installes thread/domain unhandled exception handlers and see why acad is crashing to begin with.
I can't reproduce the problem when I separate the code, I also simulated the multithreading and call from a form, but the problem doesn't show.
I solved it by testing, if the style is already the same:
If ds.Dimtxsty <> s2TextStyle.ObjectId Then ds.Dimtxsty = s2TextStyle.ObjectId
Ok, I am glad you solved it.
I usually inherit from control and install handlers for AppDomain.CurrentDomain.FirstChanceException and AppDomain.CurrentDomain.UnhandledException in the Autodesk.AutoCAD.Runtime.IExtensionApplication.Ini
I was experimenting with this, I had handler hooked on those events, but it didn't help, because I didn't go as far as you with the logging system so fatal errors still produced no information.
That example would be really helpful for many people, because you can mess up in so many ways and the result is always the same - fatal error.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.