TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: KewlToyZ on August 19, 2009, 02:08:17 PM
-
I am running this routine for building the layers in a drawing.
http://www.theswamp.org/index.php?topic=8763.30
2007-2009 verticals it worked terrific.
For some reason in 2010 it hangs up often for 5-25 seconds when I fire the command from a button call.
It works fine after I call the routine from the command line, so I am not sure why it loads so slowly from a button.
For example
In a button call:
^C^C_LRS;E-POWR-CIRC;^C^C(ticks "electrical/E-Tick Mark - POWR-3")
it seemed simple enough. But unless I ran the LRS command from the command prompt once, it tanked slowly.
Then I got curious...
^C^C_LRS;E-POWR-CIRC;(ticks "electrical/E-Tick Mark - POWR-3")
Command fired quickly after closing and opening the file again.
So I closed out of AutoCAD completely to see if it really was the cancels causing the slow commands...
I guess it was, the problem seems to be gone after 4 different test files.
I'm curious why?
I wondered if it could have something to do with the Legacy command scripting capability they put into 2010?
I'm curious if anyone else has ran into this?
-
Hmmm it still hangs on an initializing call in 2010.
Once it has ran it is fine but the first call takes a few seconds to run.
2007-2009 it runs fine, 2010 no errors it just runs slow on a first call.
http://www.theswamp.org/index.php?topic=8763.30
-
OK did a minor re-write:
(defun c:LRS ( / inslayer)
; Menu Command example: ^C^C_LRS;E-CLOK
; Thanks to Kerry Brown, CAB, and the crew at TheSwamp
; http://www.theswamp.org/index.php?topic=8763.0
(vl-load-COM)
(princ "\n Layer requested (?): ")
(princ inslayer)
;(princ "")
;===============================================================================
(defun myLayers()
; Load the default NCS layers routine and run it..
(autoload "LRD" '("LRD"))
(c:LRD)
(prompt "\n NCS layers loaded! ....\n")
; Set the layer requested as current
(command "clayer" inslayer)
)
;===============================================================================
; If the command is fired empty prompt for layer name
(if (or (null inslayer)(= inslayer nil))
(progn
(setq inslayer (getstring "\n Enter Layer Name: "))
(myLayers)
) ; end progn
) ; end if
;===============================================================================
; If the layer name is not present load all layers
(if (not (tblobjname "layer" inslayer))
(progn
(myLayers)
) ; end progn
) ; end if
; Set the layer requested as current
(command "clayer" inslayer)
;===============================================================================
;Turn off command line responses
(command "CMDECHO" 0) ;DO NOT CHANGE THIS LINE
;===============================================================================
; Get the current layer
(setq userLayer (getvar "clayer"))
; purge other layers
; Thanks to Lee Mac for this
(princ "\n Purging empty file entries.......")
(setq doc (vla-get-ActiveDocument
(vlax-get-acad-object)))
(repeat 3 (vla-purgeall doc))
(princ "\n File Purge Complete !!!!!!......")
; Print the layer name
(prompt "\n LRS Set to layer: ................ ")
(princ userLayer)
(princ "\n")
;===============================================================================
;Turn off command line responses
(command "CMDECHO" 1) ;DO NOT CHANGE THIS LINE
;===============================================================================
(princ)
)
(princ "\n LRS (layer set) routine is loaded !!!")