Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Vlisp-Activex and Entmake don't mix!

22 REPLIES 22
Reply
Message 1 of 23
Anonymous
404 Views, 22 Replies

Vlisp-Activex and Entmake don't mix!

Hello,

Here is the problem:

I have a few legacy autolisp commands for draw isometric (isoTools) and
lately I create several ones using vlisp/activex, it have been an issue for
maybe two or more years that they don't work together, have someone have
check if in A2004, do they fixed this kind of problem?

Now how the elock error occurs?

If I use a routine that makes a new textstyle and dimensionstyle using
vlisp/activex and then after that I call the command using legacy autolisp
in particular entmake, it will break on the elock error and end the autocad
session.

I have doing testing under testing, etc, but is difficult to fix, now if I
use first the legacy autolisp routine and after that the one with
vlisp/activex everything works just fine. But I cannot tell my customers how
the secuency need to be in order to avoid such behaiviour.

I have only two choices remove those commands with legacy autolisp that are
causing the error or re-write the commands using vlisp/activex but that will
be a very extensive job (I know I have to do it anyways).

Any input?

Best regards,
Luis Esquivel
Caddximation Software

Here is a piece of code showing where the error occurs.
;;-----------------------------------------------
(setq ssobj1 (ssadd)
lth (sslength ssobj)
cont 0
;; 30 degrees as radians
ang (/ (* 30 pi) 180))

(prompt "\nProcessing objects. Please wait...")

(entmake
'((0 . "BLOCK") (2 . "*U") (70 . 1) (10 0.0 0.0 0.0)))
(while (< cont lth)
(setq obj (ssname ssobj cont)
dat (entget obj)
tip (dxf 0 dat)
color (assoc 62 dat)
ltp (assoc 6 dat))
;; if not color asign it
(if (null color)
(setq color (assoc 62 (tblsearch "LAYER" (dxf 8 dat)))))
(cond
((or (= tip "INSERT") (= tip "DIMENSION"))
(progn
(if (= tip "DIMENSION")
(setq xfac 1
yfac 1
zfac 1
ins (dxf 12 dat)
rot 0)
(setq xfac (dxf 41 dat)
yfac (dxf 42 dat)
zfac (dxf 43 dat)
ins (dxf 10 dat)
rot (dxf 50 dat)))
(if (and (= xfac yfac zfac) (isplan))
(progn
(isoblk dat xfac ins rot color ltp)
(isoatt nil))
(setq
lstobj1 (append lstobj1
(list (list dat 1 0 '(0 0) nil nil)))))))
("T" (isobj dat nil)))
(setq cont (1+ cont)))

;; program breaks here!
;; with the elock error and ends the drawing session.
(setq nom (entmake '((0 . "ENDBLK"))))

(if nom
(entmake
(list '(0 . "INSERT")
'(10 0.0 0.0 0.0)
(cons 2 nom)
(cons 50 ucsrt))))
(setq entblk (entlast))
(if lstobj1
(progn
(objblk lstobj1)
(if (ssname sel2d 0)

;;...

)))

;; By using the following activex or a very similar code before

(defun createTextstyle
(doc name font height width scale / textstyles textstyle)
(setq textstyles (vla-get-textstyles doc))
(setq textstyle (vla-add textstyles name))
(vla-put-activetextstyle doc textstyle)
(vla-put-fontfile textstyle font)
(vla-put-height textstyle (* scale height))
(vla-put-width textstyle width))

(defun createDimstyle (doc name / dimstyle)
(vla-copyfrom
(setq dimstyle (vla-add (vla-get-dimstyles doc) name))
doc)
(vla-put-activedimstyle doc dimstyle))
22 REPLIES 22
Message 2 of 23
Anonymous
in reply to: Anonymous

Interesting! (every time I ask or post for something I don't get a lot of
input if any)

I know this must be a bug in AutoCAD, I was just hoping to hear any good
news.

:-(

re-write that will be the answer...
Message 3 of 23
Anonymous
in reply to: Anonymous

Hi Luis,

I think it is because you always ask all the hard questions!
Ask me somethin' easy, I'll give you an answer 😉

--

-Jason
Member of the Autodesk Discussion Forum Moderator Program


"Luis." wrote in message
news:78B81446FC28F7F20CB6B28C4104863E@in.WebX.maYIadrTaRb...
> Interesting! (every time I ask or post for something I don't get a lot of
> input if any)
Message 4 of 23
Anonymous
in reply to: Anonymous

Thank you Jason,

I have to remove two commands from my application just because of that, no
time to re-write for now.

let me think for an easy one... and I will right back.

--
le

"Jason Piercey" wrote in message
news:AF15C332355D43C3B3750FAD3EA4CC5A@in.WebX.maYIadrTaRb...
> Hi Luis,
>
> I think it is because you always ask all the hard questions!
> Ask me somethin' easy, I'll give you an answer 😉
>
> --
>
> -Jason
> Member of the Autodesk Discussion Forum Moderator Program
>
>
> "Luis." wrote in message
> news:78B81446FC28F7F20CB6B28C4104863E@in.WebX.maYIadrTaRb...
> > Interesting! (every time I ask or post for something I don't get a lot
of
> > input if any)
>
>
>
Message 5 of 23
Anonymous
in reply to: Anonymous

Luis:

It appears you're creating an anonymous block. Try out my UBLOCK routine within
the CVR15 app. If you (or anyone else) needs a temporary license let me know.
I'm curious as to whether your code to make the definition/insert is faulty or
whether the ActiveX predecessor is causing the problem. There *are* functions
you are using that you haven't included for us to inspect. I presume they
(entmake) the entities in SSOBJ.

--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ

"Luis." wrote in message
news:A995ECF9F56B80822E688AF1DD81AC51@in.WebX.maYIadrTaRb...
> Hello,
>
> Here is the problem:
>
> I have a few legacy autolisp commands for draw isometric (isoTools) and
> lately I create several ones using vlisp/activex, it have been an issue for
> maybe two or more years that they don't work together, have someone have
> check if in A2004, do they fixed this kind of problem?
>
> Now how the elock error occurs?
>
> If I use a routine that makes a new textstyle and dimensionstyle using
> vlisp/activex and then after that I call the command using legacy autolisp
> in particular entmake, it will break on the elock error and end the autocad
> session.
>
> I have doing testing under testing, etc, but is difficult to fix, now if I
> use first the legacy autolisp routine and after that the one with
> vlisp/activex everything works just fine. But I cannot tell my customers how
> the secuency need to be in order to avoid such behaiviour.
>
> I have only two choices remove those commands with legacy autolisp that are
> causing the error or re-write the commands using vlisp/activex but that will
> be a very extensive job (I know I have to do it anyways).
>
> Any input?
>
> Best regards,
> Luis Esquivel
> Caddximation Software
>
> Here is a piece of code showing where the error occurs.
> ;;-----------------------------------------------
> (setq ssobj1 (ssadd)
> lth (sslength ssobj)
> cont 0
> ;; 30 degrees as radians
> ang (/ (* 30 pi) 180))
>
> (prompt "\nProcessing objects. Please wait...")
>
> (entmake
> '((0 . "BLOCK") (2 . "*U") (70 . 1) (10 0.0 0.0 0.0)))
> (while (< cont lth)
> (setq obj (ssname ssobj cont)
> dat (entget obj)
> tip (dxf 0 dat)
> color (assoc 62 dat)
> ltp (assoc 6 dat))
> ;; if not color asign it
> (if (null color)
> (setq color (assoc 62 (tblsearch "LAYER" (dxf 8 dat)))))
> (cond
> ((or (= tip "INSERT") (= tip "DIMENSION"))
> (progn
> (if (= tip "DIMENSION")
> (setq xfac 1
> yfac 1
> zfac 1
> ins (dxf 12 dat)
> rot 0)
> (setq xfac (dxf 41 dat)
> yfac (dxf 42 dat)
> zfac (dxf 43 dat)
> ins (dxf 10 dat)
> rot (dxf 50 dat)))
> (if (and (= xfac yfac zfac) (isplan))
> (progn
> (isoblk dat xfac ins rot color ltp)
> (isoatt nil))
> (setq
> lstobj1 (append lstobj1
> (list (list dat 1 0 '(0 0) nil nil)))))))
> ("T" (isobj dat nil)))
> (setq cont (1+ cont)))
>
> ;; program breaks here!
> ;; with the elock error and ends the drawing session.
> (setq nom (entmake '((0 . "ENDBLK"))))
>
> (if nom
> (entmake
> (list '(0 . "INSERT")
> '(10 0.0 0.0 0.0)
> (cons 2 nom)
> (cons 50 ucsrt))))
> (setq entblk (entlast))
> (if lstobj1
> (progn
> (objblk lstobj1)
> (if (ssname sel2d 0)
>
> ;;...
>
> )))
>
> ;; By using the following activex or a very similar code before
>
> (defun createTextstyle
> (doc name font height width scale / textstyles textstyle)
> (setq textstyles (vla-get-textstyles doc))
> (setq textstyle (vla-add textstyles name))
> (vla-put-activetextstyle doc textstyle)
> (vla-put-fontfile textstyle font)
> (vla-put-height textstyle (* scale height))
> (vla-put-width textstyle width))
>
> (defun createDimstyle (doc name / dimstyle)
> (vla-copyfrom
> (setq dimstyle (vla-add (vla-get-dimstyles doc) name))
> doc)
> (vla-put-activedimstyle doc dimstyle))
>
>
>
Message 6 of 23
Anonymous
in reply to: Anonymous

Thank you very much John,

I think I found the workaround , I'm doing now
my last testings and will post my results here if is possible...
Message 7 of 23
Anonymous
in reply to: Anonymous

> It appears you're creating an anonymous block. Try out my UBLOCK routine
within
> the CVR15 app. If you (or anyone else) needs a temporary license let me
know.

btw, John are you using something in particular to create an anonymous
block? without using entMake and endBlock?

Another thing, do you still use in your commands (command "_.undo"
"_group")? I just want to know.

> I'm curious as to whether your code to make the definition/insert is
faulty or
> whether the ActiveX predecessor is causing the problem. There *are*
functions
> you are using that you haven't included for us to inspect. I presume they
> (entmake) the entities in SSOBJ.

Yes, I can't post the rest of the code.



Thanks,
Luis
Message 8 of 23
Anonymous
in reply to: Anonymous

Using (entmake) and (vla-xxxUndoMark)

Note that I recently found that (command ".Undo" "Mark") and (command ".Undo"
"Back") are disregarded if an Undo;Group has been started by either the
(command) or ActiveX versions, so...

(defun @cv_undo_group ()
(vla-EndUndoMark (vla-get-activedocument *acad*))
(vla-StartUndoMark (vla-get-activedocument *acad*))
)
;; *acad* should be an obvious global.

--
John Uhden, Cadlantic/formerly CADvantage
http://www.cadlantic.com
Sea Girt, NJ


"Luis." wrote in message
news:A5AEBDC0AD39406B082A31A21E90AED8@in.WebX.maYIadrTaRb...
> > It appears you're creating an anonymous block. Try out my UBLOCK routine
> within
> > the CVR15 app. If you (or anyone else) needs a temporary license let me
> know.
>
> btw, John are you using something in particular to create an anonymous
> block? without using entMake and endBlock?
>
> Another thing, do you still use in your commands (command "_.undo"
> "_group")? I just want to know.
>
> > I'm curious as to whether your code to make the definition/insert is
> faulty or
> > whether the ActiveX predecessor is causing the problem. There *are*
> functions
> > you are using that you haven't included for us to inspect. I presume they
> > (entmake) the entities in SSOBJ.
>
> Yes, I can't post the rest of the code.
>
>
>
> Thanks,
> Luis
>
>
Message 9 of 23
Anonymous
in reply to: Anonymous

Thank you John,

Basically is the same I use:

(Or AcadDoc
(SetQ AcadDoc (vla-get-activedocument (vlax-get-acad-object))))

(defun undobegin (/)
(vla-endundomark AcadDoc)
(vla-startundomark AcadDoc))

(defun undoend (/)
(vla-endundomark AcadDoc))

The only diference is that you don't have there the active document as
global, hmmm.

All right here are my results:

1) After testing a command that creates a dimension and text style using
activex first, and then another one to make or convert objects in isometric
using entmake I still get the elock violation error and autocad stops.

2) If I place the line (command "_.undo" "_begin") before the call to the
activex function to create the dimension and text styles and at the end I
put (command "_.undo" "_end") the elock error do not happen for the
following let say five calls to the isometric command that uses entmake, but
if I remove those two lines before and after with the undo command it
happens right after the first call.

Okay maybe is telling me something...

Well, I gave up this I will remove two commands that are causing this... and
will re-write with vlisp/activex. To bad...

btw, can someone post the link to Stephan Kostner preventElockError.arx? I
would like to test those two commands before as a last resort.

Best regards,
Luis

"John Uhden" wrote in message
news:382B2FCDB277A8501D9982230266A46C@in.WebX.maYIadrTaRb...
> Using (entmake) and (vla-xxxUndoMark)
>
> Note that I recently found that (command ".Undo" "Mark") and (command
".Undo"
> "Back") are disregarded if an Undo;Group has been started by either the
> (command) or ActiveX versions, so...
>
> (defun @cv_undo_group ()
> (vla-EndUndoMark (vla-get-activedocument *acad*))
> (vla-StartUndoMark (vla-get-activedocument *acad*))
> )
> ;; *acad* should be an obvious global.
>
> --
> John Uhden, Cadlantic/formerly CADvantage
> http://www.cadlantic.com
> Sea Girt, NJ
>
>
> "Luis." wrote in message
> news:A5AEBDC0AD39406B082A31A21E90AED8@in.WebX.maYIadrTaRb...
> > > It appears you're creating an anonymous block. Try out my UBLOCK
routine
> > within
> > > the CVR15 app. If you (or anyone else) needs a temporary license let
me
> > know.
> >
> > btw, John are you using something in particular to create an anonymous
> > block? without using entMake and endBlock?
> >
> > Another thing, do you still use in your commands (command "_.undo"
> > "_group")? I just want to know.
> >
> > > I'm curious as to whether your code to make the definition/insert is
> > faulty or
> > > whether the ActiveX predecessor is causing the problem. There *are*
> > functions
> > > you are using that you haven't included for us to inspect. I presume
they
> > > (entmake) the entities in SSOBJ.
> >
> > Yes, I can't post the rest of the code.
> >
> >
> >
> > Thanks,
> > Luis
> >
> >
>
Message 10 of 23
Anonymous
in reply to: Anonymous

On 02.04.2003 16:54 Luis. wrote:

>btw, can someone post the link to Stephan Kostner preventElockError.arx? I
>would like to test those two commands before as a last resort.
>
>
http://xarch.tu-graz.ac.at/autocad/code/skoster/

--
ruul
Message 11 of 23
Anonymous
in reply to: Anonymous

Thank you ruul,

The error persist... I found this comment by Owen Wengerd

The eLock is usually the result of an ARX appliction locking an
entity but not unlocking it or something prevented the proper
unlocking of the entitiy.

Actually, eLockViolation means an attempt was made to access a *document*
before locking it. In most cases it's a simple programming error where the
programmer forgot to lock the document before attempting to access it from
an application context. If it's intermittent, however, the problem may be
related to bugs in the AutoCAD ActiveX implementation whereby some internal
code is sometimes getting out of sync and causing the document to be
unlocked again before the code is finished with it. I'd suspect that the
clock speed and number of processors could be a factor. 🙂

Owen Wengerd
President, ManuSoft ==> http://www.manusoft.com
VP Americas, CADLock, Inc. ==> http://www.cadlock.com

Now a question for Owen,

It will be easy enough to create an arx app to catch and avoid such *AutoCAD
Bug*?

Regards,
Luis Esquivel

"ruul morawetz" wrote in message
news:A8B37441E9724788CD4A5ED4E4036CFA@in.WebX.maYIadrTaRb...
> On 02.04.2003 16:54 Luis. wrote:
>
> >btw, can someone post the link to Stephan Kostner preventElockError.arx?
I
> >would like to test those two commands before as a last resort.
> >
> >
> http://xarch.tu-graz.ac.at/autocad/code/skoster/
>
> --
> ruul
>
Message 12 of 23
Anonymous
in reply to: Anonymous

"Luis." schrieb:
>
> Thank you ruul,
>
> The error persist...

Luis,

I have a newer version of preventlockerror.arx. I have posted
it in customer-files. This version should handle reactors
as well.
Please try it and if your eLock error still remains then
maybe you can cut down your code to the shortest possible
example which causes the error. Maybe then I can have a look
at it.
The arx is made for 2000(i)/2002.
I would be interested to hear if this error is still around in
A2K4.

Stephan
Message 13 of 23
Anonymous
in reply to: Anonymous

Thank you Stephan,

I will tested this night, I know for sure that AutoCAD breaks exactly in
this entmake termination:
(setq nom (entmake '((0 . "ENDBLK"))))

Right after a call to add a new/update dimensionStyle and TextStyle objects
Or when I select (gripping) an object that is part of an object-reactor, and
before firing the reactor to update the objects in the reactor the elock
violation happens.

The curiosity is that if I do a reverse way first the command with the use
of entmake and next any other one with activex or reactors everything is
fine.

Also if I don't use the two commands that I have to create isometric objects
or shapes the problem is gone.

I just made the desicion to remove such commands from my application.

Best regards,
Luis

:[

"Stephan Koster" wrote in message
news:3E8B6081.92B4BB47@web.de...
> "Luis." schrieb:
> >
> > Thank you ruul,
> >
> > The error persist...
>
> Luis,
>
> I have a newer version of preventlockerror.arx. I have posted
> it in customer-files. This version should handle reactors
> as well.
> Please try it and if your eLock error still remains then
> maybe you can cut down your code to the shortest possible
> example which causes the error. Maybe then I can have a look
> at it.
> The arx is made for 2000(i)/2002.
> I would be interested to hear if this error is still around in
> A2K4.
>
> Stephan
Message 14 of 23
Anonymous
in reply to: Anonymous

Luis. wrote:
> Thank you Stephan,
>
> I will tested this night, I know for sure that AutoCAD breaks exactly in
> this entmake termination:
> (setq nom (entmake '((0 . "ENDBLK"))))
>
> Right after a call to add a new/update dimensionStyle and TextStyle objects

Is this inside _one_ command (lisp function) or are these two separate commands?
I've never seen a problem when mixing ActiveX and entmake in one lisp function.
Normally the eLock error only occurs when using first a function which
uses ActiveX and after that a function wich uses entmake.
If you use any AutoCAD command in between (for example redraw) the error
does not occur.

> Or when I select (gripping) an object that is part of an object-reactor, and
> before firing the reactor to update the objects in the reactor the elock
> violation happens.

Before firing? You mean while updating the objects the crash happens?
Can you publish a piece of code of that reactor?

> The curiosity is that if I do a reverse way first the command with the use
> of entmake and next any other one with activex or reactors everything is
> fine.

As said above only in that order of calling the commands the error appears.

> Also if I don't use the two commands that I have to create isometric objects
> or shapes the problem is gone.

What do these commands use? ActiveX or entmake?

> I just made the desicion to remove such commands from my application.

Please try my arx first if it helps. If not maybe you can show some
code so that I can reproduce the problem.

Stephan
Message 15 of 23
Anonymous
in reply to: Anonymous

> Luis. wrote:
> > Thank you Stephan,
> >
> > I will tested this night, I know for sure that AutoCAD breaks exactly in
> > this entmake termination:
> > (setq nom (entmake '((0 . "ENDBLK"))))
> >
> > Right after a call to add a new/update dimensionStyle and TextStyle
objects
>
> Is this inside _one_ command (lisp function) or are these two separate
commands?
> I've never seen a problem when mixing ActiveX and entmake in one lisp
function.

separate, now I wonder in the past two years I have the same commands in a
single file and never got the eLock error, until lately I decide to have
them individualy. hmm.

> Normally the eLock error only occurs when using first a function which
> uses ActiveX and after that a function wich uses entmake.

Thank you for the confirmation.

> If you use any AutoCAD command in between (for example redraw) the error
> does not occur.

I have not try with this (and actually you are the second person that
provides this trick to me) I will do it today.

>
> > Or when I select (gripping) an object that is part of an object-reactor,
and
> > before firing the reactor to update the objects in the reactor the elock
> > violation happens.
>
> Before firing? You mean while updating the objects the crash happens?

Yes.

I noticed that must be something with a function I use that uses "entnext"?
could be.

> Can you publish a piece of code of that reactor?

I don't have the code with me, I'm now at my day job (Project Architect). I
will do that next Monday if still is necessary.

>
> > The curiosity is that if I do a reverse way first the command with the
use
> > of entmake and next any other one with activex or reactors everything is
> > fine.
>
> As said above only in that order of calling the commands the error
appears.

Yep.

>
> > Also if I don't use the two commands that I have to create isometric
objects
> > or shapes the problem is gone.
>
> What do these commands use? ActiveX or entmake?

Entmake.

>
> > I just made the desicion to remove such commands from my application.
>
> Please try my arx first if it helps. If not maybe you can show some
> code so that I can reproduce the problem.

The eLock error is gone by using your application, excelent Stephan!, my
only concern will be that I will like to use your ARX within my commercial
application...

Thank you very much for all your help, and greetings from Tijuana, Mexico.

Luis.

btw: I noticed that after using your ARX now it shows an activex error of
null ID object, I have at the end of a drawing session a reactor that does a
clean-house and saves the objects with reactors to my own dictionary for
later use as if they where persistant reactors (I don't like to use
vlr-pers), I fix this already inside of my code. Now my question is just for
a confirmation Stephan do you release the vla-objects or do you let AutoCAD
handle that for your routines?

Sorry for this long conversation...

>
> Stephan
>
Message 16 of 23
Anonymous
in reply to: Anonymous

"Luis." wrote:
> ...
> > Can you publish a piece of code of that reactor?
>
> I don't have the code with me, I'm now at my day job (Project Architect). I
> will do that next Monday if still is necessary.

No, I think it's not necessary if the problem is fixed now.

> The eLock error is gone by using your application, excelent Stephan!, my
> only concern will be that I will like to use your ARX within my commercial
> application...

My ARX is free, you can use it even in a commercial app, as long as
you distribute both, the ARX and the text file.

> ... Now my question is just for
> a confirmation Stephan do you release the vla-objects or do you let AutoCAD
> handle that for your routines?

I am not an expert for vla-objects but in my opinion it's always
better to release all vla-objects and I try always to release them.
A lot of problems can arise if you don't do that, for example if the type
of the object changes, maybe from circle to arc, then you are lost if
you didn't release the circle object before.
I try too to keep all vla-objects local, I don't have for example globals
for the application or the document object. Creating these objects when
needed is as fast as access them via a global variable, so there is no
need to have them floating around.

Stephan
Message 17 of 23
Anonymous
in reply to: Anonymous

Vielen Dank Stephan.

Luis.
Message 18 of 23
Anonymous
in reply to: Anonymous

"Luis." wrote:
>
> Vielen Dank Stephan.
>
> Luis.

De nada.

Stephan
Message 19 of 23
Anonymous
in reply to: Anonymous

Stephan,

I decided to take the invitation to try and trash my system

Per your samples:

Command: test1
"0"

Command: test2

Should always return T
Return value: T

Command: test3
((0 . "POINT") (10 0 0 0))

Command: test4
"test"

No crashola 🙂

Any others you would like to try out?

--

-Jason
Member of the Autodesk Discussion Forum Moderator Program


"Stephan Koster" wrote in message news:3E8B6081.92B4BB47@web.de...
> I would be interested to hear if this error is still around in A2K4.
Message 20 of 23
Anonymous
in reply to: Anonymous

Jason Piercey wrote:

> No crashola 🙂
>
> Any others you would like to try out?

Jason,

thanks for the info. Seems to be fixed now in A2K4.

Stephan

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

Post to forums  

Autodesk Design & Make Report

”Boost