TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Mark on May 27, 2004, 10:50:14 AM
-
I'm wondering if I can create one of these(see below) using the DXF codes? If so, what is the minimum required codes. I can make these things using activeX but was thinking it might be faster using dxf codes.
thanks
; DXF Group Codes:
; (-1 . <Entity name: 7efebd78>)
; (0 . "AECC_POINT")
; (330 . <Entity name: 7eff0cf8>)
; (5 . "1C8F")
; (100 . "AcDbEntity")
; (67 . 0)
; (410 . "Model")
; (8 . "SVY-POINTS")
; (100 . "AecDbEntity")
; (102 . "{AEC_SUBOBJECT")
; (300 . "AeccImpPoint")
; (100 . "AecImpObj")
; (3 . "")
; (100 . "AecImpEnt")
; (171 . 0)
; (100 . "AecImpGeo")
; (10 486925.0 1.30319e+006 0.0)
; (15 1.0 0.0 0.0)
; (16 0.0 1.0 0.0)
; (210 0.0 0.0 1.0)
; (360 . <Entity name: 0>)
; (100 . "AeccImpPoint")
; (90 . 107)
; (11 486925.0 1.30319e+006 -0.5)
; (302 . "RBNK122")
; (301 . "")
; (300 . "")
; (280 . 0)
; (303 . "RBNK122")
; (304 . "")
; (305 . "")
; (10 486925.0 1.30319e+006 0.0)
; (285 . 1)
; (286 . 0)
; (170 . 3)
; (141 . 5.0)
; (306 . "Standard")
; (140 . 0.25)
; (282 . 1)
; (283 . 0)
; (284 . 1)
; (171 . 2)
; (172 . 1)
; (173 . 3)
; (287 . 1)
; (142 . 0.0)
; (288 . 1)
; (102 . "AEC_SUBOBJECT}")
; (102 . "{AEC_NULLOBJECT}")
; (100 . "AecDbGeo")
; (100 . "AeccDbPoint")
-
Mark,
If memory serves, Reini Urban used to have some templates in his library which may be a good guide.
Personally, I am sticking with ActiveX. The difference in speed < even if a couple of seconds > on a large app seems negligable [ to me ] Most users take longer than that to find a key on the keyboard. :D
regards.kerry
-
Mark,
I don't think it's a good idea to create point objects in this fashion. Since points are stored externally I really believe that using the AECC Object Model and ActiveX methods is the ONLY way to work with points.
If you can explain WHY you'd want to do otherwise, I'm all ears......
And I have yet to see where (entmake) is faster than (vlax-invoke addWhatever)
Jeff
LDD3 user/hacker
-
And I have yet to see where (entmake) is faster than (vlax-invoke addWhatever)
sounds like another contest to me..........!!
True, creating them through activex is probaly the way to go, how ever I believe you could create them dxf style them update the external datbase. It's not a big deal, just thought I'd try.
thanks fot the feedback guys
-
I also have the same test vith VBA and Sharplisp [lisp converted to C++ ARX] The Sharplisp blew them all away.
(defun c:kwb_speedtest4a (/ intcolor count oldecho stime etime )
(gc)
(setq intcolor 0
count 0
oldecho (getvar "cmdecho")
)
(setvar "cmdecho" 0)
(command "Zoom" "W" (list 0 0 0) (list 51000 51000 0))
(setq stime (getvar 'millisecs))
(repeat 50000
(command "Line"
(list 0 count 0)
(list (setq count (1+ count)) (1- count) 0)
""
)
(command "chprop" (entlast) "" "C" (setq intcolor (1+ intcolor)) "")
(or (< intcolor 255) (setq intcolor 0))
)
;;;(command "regen")
(setq etime (getvar 'millisecs))
(alert (strcat (rtos (- etime stime)) " Milliseconds"))
(setvar "cmdecho" oldecho)
(princ)
)
(defun c:kwb_speedtest4b (/ intcolor count oldecho cecolor stime etime )
(gc)
(setq intcolor 0
count 0
oldecho (getvar "cmdecho")
oldcolor (getvar "cecolor")
)
(setvar "cmdecho" 0)
(command "Zoom" "W" (list 0 0 0) (list 51000 51000 0))
(setq stime (getvar 'millisecs))
(repeat 50000
(setvar "cecolor" (itoa (setq intcolor (1+ intcolor))))
(command "Line"
(list 0 count 0)
(list (setq count (1+ count)) (1- count) 0)
""
)
(or (< intcolor 255) (setq intcolor 0))
)
;;;(command "regen")
(setq etime (getvar 'millisecs))
(alert (strcat (rtos (- etime stime)) " Milliseconds"))
(setvar "cmdecho" oldecho)
(princ)
)
(defun c:kwb_speedtest2 (/ intcolor count stime etime)
(gc)
(setq intcolor 0
count 0
)
(command "Zoom" "W" (list 0 0 0) (list 51000 51000 0))
(setq stime (getvar 'millisecs))
(repeat 50000
(entmake (list '(0 . "LINE")
(list 10 0 count 0)
(list 11 (setq count (1+ count)) (1- count) 0)
(cons 62 (setq intcolor (1+ intcolor)))
)
)
(or (< intcolor 255) (setq intcolor 0))
)
(command "regen")
(setq etime (getvar 'millisecs))
(alert (strcat (rtos (- etime stime)) " Milliseconds"))
(princ)
)
(defun c:kwb_speedtest2a (/ sp ep intcolor count stime)
(setq intcolor 0
count 0
stime (getvar 'millisecs)
)
(repeat 50000
(setq
sp (list 10 0 count 0)
ep (list 11 (1+ count) count 0)
count (1+ count)
intcolor (1+ intcolor)
)
(entmake (list '(0 . "LINE")
sp
ep
(cons 62 intcolor )
)
)
(if (> intcolor 255) (setq intcolor 0))
)
(command "regen")
(alert (rtos (- (getvar 'millisecs) stime)))
)
(defun c:kwb_speedtest2b (/ sp ep epx idl intcolor count stime)
(setq intcolor 0
count 0
idl (cons 0 "LINE")
stime (getvar 'millisecs)
)
(repeat 50000
(setq
sp (list 10 0 count 0)
epx (1+ count)
;; ep (list 11 (1+ count) count 0)
ep (list 11 epx count 0)
count (1+ count)
intcolor (1+ intcolor)
)
(entmake (list idl
sp
ep
(cons 62 intcolor )
)
)
(if (> intcolor 255) (setq intcolor 0))
)
(command "regen")
(alert (rtos (- (getvar 'millisecs) stime)))
)
(defun c:kwb_speedtest1a
(/ g_acadapp g_modelspace intcolor count stime etime)
(gc)
(setq g_acadapp (vlax-get-acad-object)
g_modelspace (vla-get-modelspace (vla-get-activedocument g_acadapp))
intcolor 0
count 0
)
(vla-zoomwindow g_acadapp
(vlax-3d-point (list 0 0 0))
(vlax-3d-point (list 51000 51000 0))
)
(setq stime (getvar 'millisecs))
(repeat 50000
(vla-put-color
(vla-addline
g_modelspace
(vlax-3d-point (list 0 count 0))
(vlax-3d-point (list (setq count (1+ count)) (1- count) 0))
)
(setq intcolor (1+ intcolor))
)
(or (< intcolor 255) (setq intcolor 0))
)
(vla-update g_acadapp)
(setq etime (getvar 'millisecs))
(vlax-release-object g_modelspace)
(vlax-release-object g_acadapp)
(alert (strcat (rtos (- etime stime)) " Milliseconds"))
(princ)
)
(defun c:kwb_speedtest1b
(/ g_acadapp g_modelspace intcolor count stime etime)
(gc)
(setq g_acadapp (vlax-get-acad-object)
g_modelspace (vla-get-modelspace (vla-get-activedocument g_acadapp))
intcolor 1
count 0
)
(vla-zoomwindow g_acadapp
(vlax-3d-point (list 0 0 0))
(vlax-3d-point (list 51000 51000 0))
)
(setq stime (getvar 'millisecs))
(repeat 50000
(vla-put-color (vla-addline g_modelspace
(vlax-3d-point (list 0 count 0))
(vlax-3d-point (list (1+ count) count 0))
)
intcolor
)
(setq count (1+ count)
intcolor (1+ intcolor)
)
(or (< intcolor 255) (setq intcolor 0))
)
(vla-update g_acadapp)
(setq etime (getvar 'millisecs))
(vlax-release-object g_modelspace)
(vlax-release-object g_acadapp)
(alert (strcat (rtos (- etime stime)) " Milliseconds"))
(princ)
)
-
These times are from Oct2002
Here are my test time results :
[edit] add test 7 [/edit]
Test 1a
31985
32016
31967
Test 1b
31953
32141
32156
Test 2
7844
7859
7846
Test VBA *may be faster if class used
18297
18484
18391
Test 4a * take a packed lunch
767672
Test 4b * ditto
146391
Test 5 * * Sharplisp
13234
13375
13328
Test 6 * *Sharplisp - Dont Blink
2531
2563
2515
Note - This is not changing colors yet, It will for the next release.
The code however is calling the setcolor method, just not changing, so i dont think the time will change much. This may be faster if class used.
Test 7 * *Sharplisp - Workaround to change color
3266
3297
3250
-
This was the VBA
Option Explicit
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private lngStart As Long
Public Sub SpeedTestVBA()
Dim objLine As AcadLine
Dim objSpace As AcadModelSpace
Dim dblStart(2) As Double
Dim dblEnd(2) As Double
Dim lngCnt As Long
Dim byColor As Byte
On Error GoTo Err_Control
Set objSpace = ThisDrawing.ModelSpace
lngStart = timeGetTime
For lngCnt = 0 To 49999
byColor = byColor + 1
dblEnd(0) = dblEnd(0) + 1
objSpace.AddLine(dblStart, dblEnd).Color = byColor
dblStart(1) = dblStart(1) + 1
dblEnd(1) = dblStart(1)
Next lngCnt
Application.Update
MsgBox timeGetTime - lngStart & " Milliseconds"
Exit_Here:
Exit Sub
Err_Control:
Select Case Err.Number
Case 6
byColor = 0
Err.Clear
Resume
Case Else
Debug.Print Err.Number; Err.Description
Err.Clear
Resume Exit_Here
End Select
End Sub
And for the sake of completeness, the Sharplisp stuff
(defun-e c:kwb_speedtest6 (/ intcolor count etime stime)
(IAcadApplication acApp (AxGetAcadApp))
;;;(acApp.ZoomWindow (point 0 0 0) (point 51000 51000 0))
(setq intcolor 1
count 0
stime (getvar 'millisecs)
)
(repeat 50000
(arx_setcolor
(arx_line (point 0 count 0) (point (1+ count) count 0))
intcolor
)
(setq count (1+ count)
intcolor (1+ intcolor)
)
(if (> intcolor 255)(setq intcolor 1))
)
(acApp.Update)
(setq etime (getvar 'millisecs))
(alert (strcat (rtos (- etime stime)) " Milliseconds"))
)
(defun-e c:kwb_speedtest7
(/ intcolor count etime stime)
(iacadapplication acapp (axgetacadapp))
;;;(acApp.ZoomWindow (point 0 0 0) (point 51000 51000 0))
(setq intcolor 1
count 0
stime (getvar 'millisecs)
)
(repeat 50000
(arx_line (point 0 count 0) (point (1+ count) count 0))
(arx_setcolor (entlast) intcolor)
(setq count (1+ count)
intcolor (1+ intcolor)
)
(if (> intcolor 255)
(setq intcolor 1)
)
)
(acapp.update)
(setq etime (getvar 'millisecs))
(alert (strcat (rtos (- etime stime)) " Milliseconds"))
)
-
well i did one test each on the following, the times are at the end of the code. (BTW I did edit your code slightly Kerry)
(defun c:kwb_speedtest1i
(/ g_acadapp g_modelspace new_line count stime etime)
(gc)
(setq g_acadapp (vlax-get-acad-object)
g_modelspace (vla-get-modelspace (vla-get-activedocument g_acadapp))
intcolor 1
count 0
)
(setq stime (getvar 'millisecs))
(repeat 50000
(setq new_line
(vlax-invoke-method
g_modelspace
'AddLine
(vlax-3d-point (list 0 count 0))
(vlax-3d-point (list (1+ count) count 0))
)
)
(vlax-release-object new_line)
(setq count (1+ count))
)
;(vla-update g_acadapp)
(setq etime (getvar 'millisecs))
(vlax-release-object g_modelspace)
;(vlax-release-object g_acadapp)
(princ (strcat (rtos (- etime stime)) " Milliseconds"))
(princ)
)
;15843.0000 Milliseconds
(defun c:kwb_speedtest2a (/ sp ep count stime)
(setq count 0
stime (getvar 'millisecs)
)
(repeat 50000
(setq
sp (list 10 0 count 0)
ep (list 11 (1+ count) count 0)
count (1+ count)
)
(entmake
(list
'(0 . "LINE")
sp
ep
)
)
)
(princ
(strcat
(rtos (- (getvar 'millisecs) stime))
" Milliseconds"
)
)
)
;4281.0000 Milliseconds"
-
That's pretty speedy for 50,000 lines heh.
-
Yep! notice the _slight_ *cough* difference between vlax-invoke-method and entmake
- Jeff
if you dig through theswamp you will find similar results, SMadsen has proven this point before.
-
(BTW I did edit your code slightly Kerry)
Yep I noticed ..
-
What happens when you put the color change back in.
Would be interesting to test vla-invoke-method ... against vla-addline ...
also
Why (vlax-release-object new_line) in each loop cycle ????
-
(defun c:kwb_speedtest1a
(/ g_acadapp g_modelspace intcolor count stime etime)
(gc)
(setq g_acadapp (vlax-get-acad-object)
g_modelspace (vla-get-modelspace (vla-get-activedocument g_acadapp))
intcolor 0
count 0
)
(vla-zoomwindow g_acadapp
(vlax-3d-point (list 0 0 0))
(vlax-3d-point (list 51000 51000 0))
)
(setq stime (getvar 'millisecs))
(repeat 50000
(vla-put-color
(setq new_line
(vlax-invoke-method
g_modelspace
'AddLine
(vlax-3d-point (list 0 count 0))
(vlax-3d-point (list (1+ count) count 0))
)
)
(setq intcolor (1+ intcolor))
)
(or (< intcolor 255) (setq intcolor 0))
(vlax-release-object new_line)
)
(vla-update g_acadapp)
(setq etime (getvar 'millisecs))
(vlax-release-object g_modelspace)
(vlax-release-object g_acadapp)
(princ (strcat (rtos (- etime stime)) " Milliseconds"))
(princ)
)
;21250.0000 Milliseconds
-
I also have the same test vith VBA and Sharplisp [lisp converted to C++ ARX] The Sharplisp blew them all away.
Hi Kerry -- If I could impose -- when you have the time could you detail some of the shortcomings you've found using sharplisp? Of course, if you wish to include the flip side you certainly can, but I'm more interested in hearing about the drawbacks of using that product -- I've come close to buying it more than once, but then I think "Feh, I should just ante up and learn arx".
THANKS!
-
Mark ,
What was your time for my original kwb_speedtest1a on your machine ??
please :D
-
Michael,
I spoke with Chad a couple of months ago. New work on Sharplisp was held untill the ObjectDCL 3.0 was issued, and that has now happened. I noticed Chad has a new File Viewer on his site which looks interesting too.
In my opinion Sharplisp is not yet a finished product. That being said, I found it quite easy to work with and got some good results. Some of the lisp constructs are very difficult to translate simply due to their nature. Lambda and mapcar come to mind. Considering his limited funding and the enormity of the project I am full of admiration for him. I will be very interested in seeing the next version.
Study wise, I am putting a lot of effort into C# at the monent ... or as much as my old head can handle. To a certain extent I am anticipating what will be in the next release of Acad.
-
Why (vlax-release-object new_line) in each loop cycle ????
based on what I understand about releasing objects, this would would be the right thing to do. that is after creating the new object it should be released. that is also true for editing an object. of course this my interpretation of what i've read. I could be _very_ wrong!
-
Mark,
nope. I dont believe they need to be released. If they were references to Excel or Access or External Objects referenced via (vla-getinterfaceobject .. then yes.
So the (setq new_line ..... could also be removed.
-
these are all based on your stuff Kerry
kwb_speedtest4a
don't have time for this one today!
kwb_speedtest4a
don't have time for this one today!
kwb_speedtest2
5016
kwb_speedtest2a
4907
kwb_speedtest2b
4922
kwb_speedtest1a
17860
kwb_speedtest1b
17828
machine specs
http://www.theswamp.org/swamp.files/mark/cpuz.htm
-
And I have yet to see where (entmake) is faster than (vlax-invoke addWhatever)
Ok, so as I was typing that I sadi to myself "Self, you haven't actually tested this, it's based on the poramming aspect, so why are you subjecting yourself to the possible results."
To which I responded: "Naw, it's probably not that big a deal anyway....."
Thanks, Kerry and Mark for the enlightenment.
Now for the next logical question....Why such a drastic difference? Even after running the different benches it seems like an Erase/slect/return takes longer on the lines that were created with activex.......
Jeff
-
*I'm not gonna say anything* :)
Nice tests, Kerry and Mark
-
Michael,
I spoke with Chad a couple of months ago. New work on Sharplisp was held untill the ObjectDCL 3.0 was issued, and that has now happened. I noticed Chad has a new File Viewer on his site which looks interesting too.
In my opinion Sharplisp is not yet a finished product. That being said, I found it quite easy to work with and got some good results. Some of the lisp constructs are very difficult to translate simply due to their nature. Lambda and mapcar come to mind. Considering his limited funding and the enormity of the project I am full of admiration for him. I will be very interested in seeing the next version.
Study wise, I am putting a lot of effort into C# at the monent ... or as much as my old head can handle. To a certain extent I am anticipating what will be in the next release of Acad.
Thank you Kerry. As I vaguely recall I had come to somewhat similar conclusions after perusing the SharpLisp on-line documentation. It is an interesting product, and Chad certainly is a hard working, intellligent programmer. I wish him and his endeavors much luck and success, but for now SharpLisp sits in my undecided folder.
I used C# for my last project at university. I like it most of it; pretty clean syntax, probably the most elegant language I've coded in. I don't care for the verbose way they implemented properties though. Nonetheless, your crystal ball is functioning pretty well I think - investing in C# is probably not a bad way to go, certainly in the bigger picture too (outside the AutoCAD customization world). Still, I'm leaning towards C++.NET ... at the end of the day, there are still some things that can only be done using said language ... and I prefer it's syntax, as cryptic as it is sometimes. Now if I could just find the time to seriously knuckle down and pound the books & keys ...
Thanks for sharing your thoughts Kerry :)
Michael.