Does ActiveX have an impact on AutoLISP's speed?

Does ActiveX have an impact on AutoLISP's speed?

surfer96
Advocate Advocate
2,433 Views
23 Replies
Message 1 of 24

Does ActiveX have an impact on AutoLISP's speed?

surfer96
Advocate
Advocate

Does using ActiveX methods have an impact on AutoLISP's calculation speed? Will AutoLISP get faster, slower or stay the same?

I don't mean addressing some external program like Excel or whatever, but the use of "genuine" AutoCAD methods such as creating or editing objects like lines or circles via vla- or vlax-methods. Is this faster or slower compared with pure AutoLISP using simple Autodesk commands like "_line" or "_circle"?

0 Likes
Accepted solutions (3)
2,434 Views
23 Replies
Replies (23)
Message 2 of 24

doaiena
Collaborator
Collaborator
Accepted solution

(repeat 20000 (command "circle" (list 0 0 0) 10)) - 51.77 sec

(repeat 20000 (vla-AddCircle (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) (vlax-3d-point 0 0 0) 10)) - 12.07 sec

 

I hope this answers your question.

EDIT:

As pointed out by @ВeekeeCZ

(repeat 20000 (entmake (list '(0 . "CIRCLE") '(10 0 0 0) '(40 . 10)))) - 8.90 sec

Message 3 of 24

ВeekeeCZ
Consultant
Consultant
Accepted solution

@doaiena wrote:

(repeat 20000 (command "circle" (list 0 0 0) 10)) - 51.77 sec

(repeat 20000 (vla-AddCircle (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) (vlax-3d-point 0 0 0) 10)) - 12.07 sec

 

I hope this answers your question.


 

...and possibly the fastest:

(repeat 20000 (entmake (list '(0 . "CIRCLE") '(10 0 0 0) '(40 . 10))))

Message 4 of 24

surfer96
Advocate
Advocate

So ActiveX is faster than pure AutoLISP?

0 Likes
Message 5 of 24

doaiena
Collaborator
Collaborator

In most cases Visual lisp functions are faster than Autolisp equivalent ones.

0 Likes
Message 6 of 24

surfer96
Advocate
Advocate

What does (0 . "CIRCLE") exactly mean in this case?

The AutoCAD command "_CIRCLE", the AutoCAD object property "circle", some DXF-ralated definition or something else?

Can any kind of AutoCAD object, e.g. a 3D face, be created with "entmake"?

0 Likes
Message 7 of 24

ВeekeeCZ
Consultant
Consultant

@surfer96 wrote:

What does (0 . "CIRCLE") exactly mean in this case?

The AutoCAD command "_CIRCLE", the AutoCAD object property "circle", some DXF-ralated definition or something else?

Can any kind of AutoCAD object, e.g. a 3D face, be created with "entmake"?


 

This is what you can call "pure" AutoLISP. Making the entities by creating their definition. HERE is a necessary minimum data to build the most of entities. 

 

Using AutoCAD's commands in AutoLISP environment is probably most easy, but by far the slowest way you can image. 

Message 8 of 24

surfer96
Advocate
Advocate

I think I found the answer, "entmake" refers to DXF group code, right?

 

Group codes Description

100

Subclass marker (AcDbCircle)

39

Thickness (optional; default = 0)

10

Center point (in OCS). DXF: X value; APP: 3D point

20, 30

DXF: Y and Z values of center point (in OCS)

40

Radius

210

Extrusion direction. (optional; default = 0, 0, 1). 
DXF: X value; APP: 3D vector

220, 230

DXF: Y and Z values of extrusion direction

0 Likes
Message 9 of 24

surfer96
Advocate
Advocate

Is using AutoCAD's commands in AutoLISP slow because calculation kind of switches between AutoLISP and AutoCAD all the time? Is that right in simple words...

0 Likes
Message 10 of 24

ВeekeeCZ
Consultant
Consultant

Yes, type keywords "circle dxf" or "lwpolyline dxf" to the help, you'll get this as the very first link.

Or in drawing, type (entget (car (entsel)))

0 Likes
Message 11 of 24

ВeekeeCZ
Consultant
Consultant

@surfer96 wrote:

Is using AutoCAD's commands in AutoLISP slow because calculation kind of switches between AutoLISP and AutoCAD all the time? Is that right in simple words...


 

I would say it's because all the graphics which remains active during processing the command (like running osnaps, ortho... so on...). And the complexity of autocad's commands.

0 Likes
Message 12 of 24

dgorsman
Consultant
Consultant

It's highly unlikely code will be looping 20k+ times, and even then it's only a small difference.  For the most part the end user won't know the difference.  Use whatever makes for the most concise and easiest to maintain code.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 13 of 24

rkmcswain
Mentor
Mentor
Accepted solution
@dgorsman wrote:

It's highly unlikely code will be looping 20k+ times, and even then it's only a small difference.  For the most part the end user won't know the difference.  Use whatever makes for the most concise and easiest to maintain code.

I agree with that, I have used all three methods at various times.

FWIW - the time is takes using (command) is affected by CMDECHO and possibly NOMUTT. I did some testing back in 2007 and updated it in 2016.

R.K. McSwain     | CADpanacea | on twitter
Message 14 of 24

surfer96
Advocate
Advocate

In case geometry is generated via ENTMAKE, will it have to be transformed to a vla-object by (vlax-ename->vla-object (...)) before you can further use an ActiveX function on it? And if so, will the transformation take considerable time?

I'm thinking of creating (between 1.000 and 10.000) random based drawing objects (e.g. lines, polylines, regions and 3d faces) demanding millions of loop executions before meeting the loop's conditions. The geometry created will definiteley need ActiveX functions wihin the loop.

In case the transformation to vla-objects would take a lot of time, ENTMAKE might not be an advantage? Or will it still be faster than working with ActiveX right from the start?

0 Likes
Message 15 of 24

doaiena
Collaborator
Collaborator

There isn't a simple "YES" or "NO" answer to your question. It is highly code dependant. You would have to test what is faster for your case. I personally would stick with vla-add functions.

0 Likes
Message 16 of 24

martti.halminen
Collaborator
Collaborator

A further thought for massive object creation tasks: if you do it WITHOUT using ActiveX, you could run the task using AutoCAD Core Console, which would be even faster as it doesn't need to waste any time drawing the objects.

 

- doesn't help in your case, though, unless you can move the ActiveX operations on the results to a separate program.

 

-- 

0 Likes
Message 17 of 24

surfer96
Advocate
Advocate

Needing a list of regions with their areas as oject properties, I don't see any way to work around ActiveX in this case...

0 Likes
Message 18 of 24

ActivistInvestor
Mentor
Mentor

Your best option might be to use Active with ObjectDBX from lisp, creating the objects in an external database that's not open in the drawing editor, allowing you to avoid the significant overhead of undo recording and Graphics generation. After the objects have been created and the database has been saved it can then be opened in the drawing editor if needed.

 


@surfer96 wrote:

Needing a list of regions with their areas as oject properties, I don't see any way to work around ActiveX in this case...


 

Message 19 of 24

surfer96
Advocate
Advocate

I've had a brief look at the use of ObjectDBX with LISP and it seems as if ObjectDBX doesn't support selection sets?

If that's correct, how can objects be selected then? Is there anything in ObjectDBX to replace selection sets like:

 

(setq ss (ssget "_x" '((410 . "Model"))))  ; select anything in model space

or

(setq ss (ssget "_X" '((0 . "REGION"))))  ; select all regions

?

0 Likes
Message 20 of 24

ActivistInvestor
Mentor
Mentor

That's correct, there is no support for selection sets in ObjectDBX. You would have to find the objects manually by scanning the model or paper space collection, which isn't really all that hard to do.

 

 


@surfer96 wrote:

I've had a brief look at the use of ObjectDBX with LISP and it seems as if ObjectDBX doesn't support selection sets?

If that's correct, how can objects be selected then? Is there anything in ObjectDBX to replace selection sets like:

 

(setq ss (ssget "_x" '((410 . "Model"))))  ; select anything in model space

or

(setq ss (ssget "_X" '((0 . "REGION"))))  ; select all regions

?


 

0 Likes