C
C#4mo ago
dopefish2112

AutoCAD Fabrication Plugin Exception

I am trying to perform some simple manipulations on autocad objects. The API documentation and examples show using a collection Job.Items. Whenever I invoke this I get an unhandled exception: attempted to access protected memory and the code crashes.
9 Replies
oke
oke4mo ago
this usually indicates pointers to memory space outside of the program's memory space. very likley youre not setting something up right, or a broken lib (very not likely) can you give code?
Denis
Denis4mo ago
This is very vague, please add more $details
MODiX
MODiX4mo ago
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
dopefish2112
dopefish21124mo ago
Thanks for taking the time to reply everyone. code can be found here https://pastebin.com/5phx8T4M epxected behaviour when invoking the job.items collection is to a collections of objects of type Item from the Fabrication API. what i get is this https://pastebin.com/mnU4cZPg i have tried to bypass this using actual selection set filtering but I can not get any variables of type Item to have any value besides null
Pastebin
Fab Plugin - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin
Execption Details - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Denis
Denis4mo ago
Have you consulted the Autodesk API documentation? Are you able to debug your plugin? To debug CAD plugins you can at the very least place a Debugger.Launch(); in your code. Once that part of your code runs, you'll get a prompt to either connect or start a visual studio instance for debugging. I have experience with other CAD systems. As each system's API can be quite different, even from the same company, it isn't that simple to assist you. Do you have access to Autodesk dev support? Wild guess here... The ent variable is retrieved from the transaction tr using a selection id. Shouldn't you get your selection from the document instead of the transaction? You say "expected" behavior. Based on your previous plugins or the documentation?
dopefish2112
dopefish21124mo ago
Thank you for taking the time to respond. I have consulted the API documentation as well as forums and classes from the dev team that released the API. Most of this code is copy pasta from API and dev examples. I am debugging using Visual Studio I do not have access to Autodesk Dev Support the ent variable should have the doc inherited from the selection Result. See below. If i am doing that wrong please let me know. Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Editor ed = doc.Editor; TypedValue[] typeArray = new TypedValue[1]; typeArray[0] = new TypedValue((int)DxfCode.Start, "MAPS_SOLID"); SelectionFilter selFilter = new SelectionFilter(typeArray); PromptSelectionResult selResult = ed.GetSelection(selFilter); Expected behaviour is based on API docs, forum posts and an AU class showing the code working in the manner expected.
Denis
Denis4mo ago
Unfortunately I do not work with AutoCAD. I work with 3D cads for engineering and architecture. Nevertheless, I feel that it does not make sense to retrieve an entity from a transaction and it should be done from the active document instead My DMs are open for you, if you wish to have a call and try to solve this together. There isn't too much documentation online, as far as I can see, and even if there is, it's copy pasta of the same thing over and over again Is this one of your sources for Job.Items?
dopefish2112
dopefish21124mo ago
yes it is. in factthe lateset post on there is mine