TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: dussla on December 24, 2009, 09:36:29 AM
-
(setq sela (ssget "x" ) )
(command "change" sela "" "P" "c" "251" "")
hi
friend , i need your help again ~~~
above lisp routine is to change color
but that routine is very slow in big dwg file
is there the most fast routine to change color ~
i will wait freinds answer ~
mery chrismas
-
Either of these:
(defun c:cCol1 (/ i ss ent)
(vl-load-com)
(if (setq i -1 ss (ssget "_X"))
(while (setq ent (ssname ss (setq i (1+ i))))
(vla-put-color (vlax-ename->vla-object ent) 251)))
(princ))
(defun c:cCol2 (/ i ss ent elst)
(if (setq i -1 ss (ssget "_X"))
(while (setq ent (ssname ss (setq i (1+ i))))
(setq elst (entget ent))
(if (assoc 62 elst)
(entmod (subst (cons 62 251) (assoc 62 elst) elst))
(entmod (append elst (list (cons 62 251)))))))
(princ))
Not sure which is quicker
-
You might find this thread to be useful.
http://www.theswamp.org/index.php?topic=55.0
-
Interesting result, on a SelectionSet of 10,000 points:
<< ActiveX took: 1.1700 secs. >>
<< Entmod took: 0.9360 secs. >>
<< ActiveX took: 1.1390 secs. >>
<< Entmod took: 0.9670 secs. >>
<< ActiveX took: 1.1240 secs. >>
<< Entmod took: 0.9830 secs. >>
(defun c:cCol1 (/ i ss ent time)
(vl-load-com)
(setq time (getvar "millisecs"))
(if (setq i -1 ss (ssget "_X"))
(while (setq ent (ssname ss (setq i (1+ i))))
(vla-put-color (vlax-ename->vla-object ent) 251)))
(princ (strcat "\n<< ActiveX took: "
(rtos (/ (- (getvar "millisecs") time) 1000.) 2 4) " secs. >>"))
(princ))
(defun c:cCol2 (/ i ss ent elst time)
(setq time (getvar "millisecs"))
(if (setq i -1 ss (ssget "_X"))
(while (setq ent (ssname ss (setq i (1+ i))))
(setq elst (entget ent))
(if (assoc 62 elst)
(entmod (subst (cons 62 251) (assoc 62 elst) elst))
(entmod (append elst (list (cons 62 251)))))))
(princ (strcat "\n<< Entmod took: "
(rtos (/ (- (getvar "millisecs") time) 1000.) 2 4) " secs. >>"))
(princ))
-
Just out of curiousity...
Command: tocolor
<< FULL ActiveX took: .484 secs. >>
Command:
Command:
TOCOLOR
<< FULL ActiveX took: .469 secs. >>
Command:
Command: ccol1
<< ActiveX took: .61 secs. >>
Command:
Command: ccol2
<< Entmod took: .953 secs. >>
(defun c:ToColor (/ time ss)
(setq time (getvar "millisecs"))
(if (setq ss (ssget "_X"))
(progn
(vlax-for x (setq ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))
(vla-put-color x 251))
(vla-delete ss)))
(princ (strcat "\n<< FULL ActiveX took: " (rtos (/ (- (getvar "millisecs") time) 1000.) 2 4) " secs. >>"))
(princ))
-
Ooo.. get you :-P
-
That is great to know - I may have to start using that method a bit more ;-)
On 10,000 points
<< ActiveX took: 1.0610 secs. >>
<< Entmod took: 0.9050 secs. >>
<< FULL ActiveX took: 0.7950 secs. >>
<< ActiveX took: 1.0460 secs. >>
<< Entmod took: 0.9680 secs. >>
<< FULL ActiveX took: 0.7800 secs. >>
Nice one Alan :-)
So I'm guessing "vlax-ename->vla-object" takes up the most time.
-
Here is my attempt
(defun C:axcol (/ acapp adoc color pfs time)
(setq adoc (vla-get-activedocument
(setq acapp (vlax-get-acad-object)
)
)
)
(setq time (getvar "millisecs"))
(setq color (vla-getinterfaceobject acapp
(strcat "AutoCAD.AcCmColor." (itoa (atoi (getvar "acadver"))))))
(vla-put-colormethod color acColorMethodByACI)
(vla-put-colorindex color 251)
(setq pfs (vla-get-pickfirstselectionset adoc))
(vlax-invoke-method pfs 'Clear)
(vla-select pfs acselectionsetall)
(vlax-for a pfs
(vla-put-truecolor a color)
)
(vlax-release-object color)
(princ (strcat "\n<< ActiveX took: "
(rtos (/ (- (getvar "millisecs") time) 1000.) 2 4) " secs. >>"))
(setq time (getvar "millisecs"))
(princ)
)
Result:
11,000 circles first run
<< Full ActiveX took: 1.7350 secs. >>
11,000 circles second run
<< Full ActiveX took: 1.4840 secs. >>
11,000 points first run
<< Full ActiveX took: 1.0160 secs. >>
11,000 points second run
<< Full ActiveX took: 0.9220 secs. >>
~'J'~
-
Yeah, I tested this a while back, out of curiosity. It would be even faster if vla-get-activedocument is a global variable and already defined. :wink:
If you notice, more of my stuff (lately) has that method over anything else.
From what I remember, repeat was even faster than while, but don't quote me on that.
That is great to know - I may have to start using that method a bit more ;-)
On 10,000 points
<< ActiveX took: 1.0610 secs. >>
<< Entmod took: 0.9050 secs. >>
<< FULL ActiveX took: 0.7950 secs. >>
<< ActiveX took: 1.0460 secs. >>
<< Entmod took: 0.9680 secs. >>
<< FULL ActiveX took: 0.7800 secs. >>
Nice one Alan :-)
So I'm guessing "vlax-ename->vla-object" takes up the most time.
-
Hi,
Instead of using (ssget "_X"), it should be a little faster to run directly trough the entire database
(defun c:dbToColor (/ time)
(setq time (getvar "millisecs"))
(vlax-for l (vla-get-Layouts
(vla-get-ActiveDocument (vlax-get-acad-object))
)
(vlax-for o (vla-get-Block l)
(vla-put-color o 256)
)
)
(princ (strcat "\n<< FULL ActiveX (w/out ssget) took: "
(rtos (/ (- (getvar "millisecs") time) 1000.) 2 4)
" secs. >>"
)
)
(princ)
)
You can have a look here (http://www.theswamp.org/index.php?topic=26243.0) too
-
Hi,gile!
thanks!
Provide you with the program is the fastest!