.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

acedInvoke will not work in correct drawing

1 REPLY 1
Reply
Message 1 of 2
drauckman
636 Views, 1 Reply

acedInvoke will not work in correct drawing

I am trying to customize AutoCAD Electrical which unfortunately has all the Electrical functionality written in Lisp.  I need to use acedInvoke extensively in order to utilize the Electrical API which is all Lisp commands.  Originally I was opening a document then running some drawing automation functions to place blocks in the drawing which worked fine since the command was called from the command line of the drawing I wanted to work on.

 

If I have a drawing, say for example by default when you open AutoCAD: Drawing1.dwg and then I run my .NET command which opens another drawing, maximizes it and then sets it as the mdicurrentdocument and then I run an Electrical command using acedInvoke it will draw in Drawing1.dwg rather than the drawing I opened and deliberatly set it as the current drawing.  The Lisp code returns the entity name of the objects it draws and when it returns it to my .NET code and I try to access that entity to modify some attributes it gives an error saying that it is not in the current drawing. 

 

Why does .NET work on the drawing I am expecting it to, but acedInvoke refuses to acknowledge when a new drawing is open and has focus?

 

If I use CommandFlags.Session and then close the Drawing1.dwg so AutoCAD is in a zero document state, and then open my desired drawing to work on and use acedInvoke to call an Electrical Lisp command to place a block it will not place any block and returns a null value everytime it is called.

 

I have tried every possible iteration and I am almost convinced that it is impossible to use acedInvoke when you are trying to batch process drawings through .NET. 

 

The only last thing I can think of is that there is another PInvoke command to call, or something buried in the ObjectARX documentation that I need to call that will cause whatever underlying code that is causing acedInvoke to stick to the wrong, or no document to actually update where it is pointing to so that it works on the correct document.

 

Does anyone know anything about how to overcome this?  I have been staying away from other methods of invoking Lisp commands since I read that the acedInvoke is synchronous which is important in the application I am writing.

1 REPLY 1
Message 2 of 2
drauckman
in reply to: drauckman

I have noticed that when I used CommandFlags.Modal and get rid of my logic that closes and opens a drawing (I just manually open a drawing and set it in modelspace), that the acedInvoke function will be called sucessfully and will place objects in the drawing.  If i switch to CommandFlags.Session then thats when everything stops working.

 

If I have CommandFlags.Modal and try to open a drawing, make it the active drawing and then call the acedInvoke, all of the blocks show up in the drawing that I originally ran my .NET command from.

 

So can acedInvoke be used in CommandFlags.Session mode?  This does not seem to be the case.  Since these functions return the entity name of what they inserted I need this data, and the other methods of calling lisp functions do not seem to have this functionality. 

 

I really hope that Autodesk has created a situation where they have vertical products written in Lisp, and they have this great .NET API but there is no way to utilize the vertical products functionality (At least when utilizing the .NET power to open/close documents).  Does this mean that I am going to have to re-write all of the AutoCAD Electrical functionality that I want to use across multiple documents to .NET????

 

Is there any functionality to use CommandFlags.Session and be able to tell whatever part of AutoCAD that is not recognizing that the current document, which is the ONLY OPEN DOCUMENT, is the document that acedInvoke is supposed to work on?  It should be apparant from a programming perspective that if you invoke a LIsp command (and I know Lisp is document based, but I am invoking it on the open document, the only document that is visible, and the only document in the document collection, and the only document that is returned in the Electricals open document return function) that there should be enough logic for the software to figure this out.

 

Another thing I noted is that when I am in CommandFlags.Session that whenever the acedInvoke is run that autocad spits out that it was an invalid AutoCAD command in the editor command window.  Why? It is not invalid, it is defined, you can type it in manually and it runs, you can use it in modal and it runs, why would it just bomb like this?

 

I am not sure what fundamental point I am miissing but I have tried everything, except for what I am hoping that someone points out is a function along the lines of AutoCADInvokeDocument = MDIActiveDocument.........

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost