Mr. marko_ribar my cmdecho is "0" otherwise it takes too long to complete because of the text window refresh.
|
Mr. marko_ribar my cmdecho is "0" otherwise it takes too long to complete because of the text window refresh.
Try this routine - it is your perf.lsp just converted to Visual Lisp
(my times are now much much faster) :
M.R.Code:(defun c:perf() (setq osm (getvar 'osmode)) (setq cmde (getvar 'cmdecho)) (setvar 'osmode 0) (setvar 'cmdecho 0) (vl-cmdf "'time" "r" "") (setq i 0 p0 (list 0 0 0) p1 (list 0 1000 0)) (vl-load-com) (setq msp (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)))) (repeat 1000 (setq p0 (list (* i 150) 0 0) p1 (list (* i 150) 1000 0) ) (setq ptl (list p0 p1) ) (setq ptl (apply 'append ptl)) (setq pts (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (1- (length ptl)))) ptl ) ) ) (setq plin (vla-addpolyline msp pts)) (vlax-put-Property plin 'ConstantWidth 10) (vla-update plin) (vlax-release-object plin) (setq i (1+ i)) ) (setvar 'osmode osm) (setvar 'cmdecho cmde) (vl-cmdf "'time" "d" "") (princ) )
BTW, you can start perf.lsp from empty PaperSpace and time will be even faster, and in the end switch to ModelSpace to see result...
Honestly I don't like ActiveX method very much and don't prefer if I do not really need it. of course optimization is always an option but I would be very happy If only I could understand what causes 2011 (command method) to slow down??
just try the entmake, simple and faster;
ps: beware that your polylines are old type, they are not LWpolyline.Code:(defun c:perf() (vl-cmdf "'time" "r" "") (setq i 0 base (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 410 "Model")(cons 43 10.)(cons 90 2))) (repeat 1000 (setq p0 (list (* i 150) 0) p1 (list (* i 150) 1000) ) (entmake (append base (list (cons 10 p0) (cons 10 p1)))) (setq i (1+ i)) ) (vl-cmdf "'time" "d" "") (princ) )
ok, perhaps I do not understand Visible/Invisible. The farther I zoom out, the slower the program seems to run. Then if I pan so the lines wont show up on the screen it reduces the time. But I cant seem to get it to run at 12 seconds no matter what. I'm at 5 seconds right now, zoomed way out (farther than I will ever be zoomed for any actual work)
Code:Command: perf Current time: Thursday, February 10, 2011 9:19:10:485 AM Times for this drawing: Created: Thursday, February 10, 2011 9:17:36:746 AM Last updated: Thursday, February 10, 2011 9:17:36:746 AM Total editing time: 0 days 00:01:33:763 Elapsed timer (on): 0 days 00:00:05:076 Next automatic save in: <disabled> Command: rea REGENALL Regenerating model. Command: Specify opposite corner: Command: e ERASE 1000 found Command: perf Current time: Thursday, February 10, 2011 9:19:33:084 AM Times for this drawing: Created: Thursday, February 10, 2011 9:17:36:746 AM Last updated: Thursday, February 10, 2011 9:17:36:746 AM Total editing time: 0 days 00:01:56:362 Elapsed timer (on): 0 days 00:00:02:291 Next automatic save in: <disabled>
Here is code for LWpolyline, but nevertheless times are slower then your code with (entmake) :
M.R.Code:(defun c:perf() (setq osm (getvar 'osmode)) (setq cmde (getvar 'cmdecho)) (setvar 'osmode 0) (setvar 'cmdecho 0) (vl-cmdf "'time" "r" "") (setq i 0 p0 (list 0 0) p1 (list 0 1000)) (vl-load-com) (setq msp (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)))) (repeat 1000 (setq p0 (list (* i 150) 0) p1 (list (* i 150) 1000) ) (setq ptl (list p0 p1) ) (setq ptl (apply 'append ptl)) (setq pts (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (1- (length ptl)))) ptl ) ) ) (setq plin (vla-addlightweightpolyline msp pts)) (vlax-put-Property plin 'ConstantWidth 10) (vla-update plin) (vlax-release-object plin) (setq i (1+ i)) ) (setvar 'osmode osm) (setvar 'cmdecho cmde) (vl-cmdf "'time" "d" "") (princ) )
p.s. I can't now use EDIT option when I am logged on (I didn't wanted to put this message in new post, but after one with my Visual Lisp code)
Last edited by marko_ribar; 2011-02-11 at 09:59 AM. Reason: attaching my svf file...
Hi there,
thanks to everyone who put effort on this topic. I have compared endless system variables finding out neither of them had any effect on this particular problem.
Rather I have found out that it is another issue which is created by "BHATCH" and can be resolved by "OSNAP"
below is the code to compare two states of the autocad 2011. if you execute the following function first it will create a rectangle, hatch its interior with bhatch and run the polyline creator "perf" subroutine. This first cycle will be slow, than it will erase all and turn osnap off and run "perf" again. The second result is faster in order of magnitude in my trials. 20 second vs 1 sec.
Don't get it wrong, even if the osnap is off you experience slow performance! You need to enter (vl-cmdf "osnap" "off") no matter what.
I still didn't understand why this is happening and want to submit a bug report or contact with developers for a reasonable solution rather than what I've found by myself. For this matter I'm asking for your help again to point me to the right people and the proper way to contact autodesk help.
Code:(defun c:comp() (princ "\nFirst run in slow mode")(read-line) (vl-cmdf "rectangle" (list 0 0) (list 1000 1000)) (vl-cmdf "zoom" "s" "0.001") (vl-cmdf "bhatch" "s" "l" "" ""); BHATCH is what makes the system slow down! (vl-cmdf "erase" "all" "") (perf) (princ "\nNow it will run faster") (graphscr) (read-line) (vl-cmdf "erase" "all" "") (vl-cmdf "osnap" "off" ); and OSNAP takes everything back to normal... (perf) (graphscr) (princ "\nLets compare the results")(read-line)(textscr) (princ) ) (defun perf() (vl-cmdf "'time" "r" "") (setq i 0) (repeat 1000 (setq p0 (list (* i 150) 0) p1 (list (* i 150) 1000) ) (vl-cmdf "pline" p0 "w" "10" "10" p1 "" ) (setq i (1+ i)) ) (vl-cmdf "'time" "d" "") (princ) )
Last edited by serhanbakir298323; 2011-02-11 at 12:39 PM.
Now, when you discovered what was wrong, why don't you put these lines into your acad2011doc.lsp, so you can always have optimized CAD for LISP routines environment, and backup original acad2011doc.lsp, so you can always put it back... Add these two lines at the end of C:\Program Files\Autodesk\AutoCAD 2011\Support\acad2011doc.lsp :
M.R.Code:(vl-cmdf "osnap" "off") (setvar 'cmdecho 0)
Why not simplify your setup and use the acaddoc.lsp file. This is a user / cad manager generated file and will not get modified from a installation repair or update. It is recommended to not modify the acad20XXdoc.lsp or acad20XX.lsp files, as those are supplied by Autodesk and may get modified by updates or repairs to AutoCAD.
If you have a technical question, please find the appropriate forum and ask it there.
You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
jUSt
Hello,
I wonder if anybody tried out the comparison code that I submitted ("c:comp") and do you experience the same behavior like I do? The issue isn't where to put (vl-cmdf "osnap" "off"), the main questions are why bhatch causes this slow down and how osnap off command resolves it??? It doesn't make any sense really...
I actually tried this today - in the year 2020, in both Autocad Architecture 2021, as well as in Autocad 2007.
The results are stunning:
The process (both the before and after) run:
Elapsed timer (on): 0 days 00:02:41:000 Autocad Architecture 2021
Elapsed timer (on): 0 days 00:00:04:182 Autocad 2007
4 seconds in 2007 vs 2min 41 sec in 2021!
I arrived here because I noticed that most of my lisp routines that do some sort of repeating (like I routine I have for drawing window pane divisions) run decidedly slower in 2021 than they do in 2007 (on the same machine).
And to be clear, my ACA2021 isn't running sluggish in general. I have various tweaks like restricting when the ribbon appears that keep my drafting smoothly. It's just when I run lisp routines that the speed difference is noticeable.