Search the Community
Showing results for tags 'layer rename'.
-
Running a function from DCL button causes crash
jbennett134 posted a topic in AutoLISP, Visual LISP & DCL
*Disclaimer* I'm not sure where this code came from, it's probably hashed together from several forum posts. I'm working on revising this layer renamer that didn't quite work. I've got the dialog box setup and working fine. I've got the layer renaming functions setup and working fine. The problem is when I try to execute the layer renaming function from the dialog box it crashes. I think it's getting stuck in a loop because the VLIDE gets stuck until I close the AutoCAD drawing and open a new one. I've simplified the code down for brevity. If any can take a look at it and give some suggestions I'd be very grateful. Thanks in advance! ;|------BEGIN---LAYER RENAMER DIALOG BOX---------------------------------------------------------------|; (defun C:layerRenamer (/ dcl_id fn fname) (vl-load-com) (create_dialog) (setq dcl_id (load_dialog fname)) (if (not (new_dialog "layerRenamer" dcl_id)) (exit) ) ;if (action_tile ;This action tile causes a crash when using the UnitLayer function. It works fine when using the testFunction. "btnUnit" "(c:unitLayer)" ) (start_dialog) (unload_dialog dcl_id) (vl-file-delete fname) (princ) ) (defun create_dialog () (setq fname (vl-filename-mktemp "dcl.dcl")) (setq fn (open fname "w")) (write-line "layerRenamer : dialog { label = \"Automated Layer Renaming - V06-08-15\"; : column { : boxed_column { : button { key = \"btnUnit\"; label = \"Fix Standard Unit Layers\"; is_default = false; } } : boxed_row { : button { key = \"cancel\"; label = \"Close\"; is_default = true; is_cancel = true; } } } }" fn ) (close fn) ) ;|------END-----LAYER RENAMER DIALOG BOX---------------------------------------------------------------|; ;|------BEGIN---BASIC RENAMING FUNCTION----------------------------------------------------------------|; (defun c:renameLayer ( oldLayer newLayer / ss i ent ) (cond ((and (tblsearch "layer" oldLayer) (not (tblsearch "layer" newLayer))) (command "._rename" "la" oldLayer newLayer) ) ((and (tblsearch "layer" oldLayer)(tblsearch "layer" newLayer)) (setq ss (ssget "x" (list (cons 8 oldLayer)))) (setq i -1) (repeat (sslength ss) (setq ent (entget (ssname ss (setq i (1+ i)))) ent (subst (cons 8 newLayer) (cons 8 (cdr (assoc 8 ent))) ent) ) (entmod ent) ) ) ((not (tblsearch "layer" oldLayer)) (prompt (strcat "\nLayer " oldLayer " not found. ")) ) ) (princ) ) ;|------END-----BASIC RENAMING FUNCTION----------------------------------------------------------------|; ;|------BEGIN---DRAWING SPECIFIC RENAMING FUNCTIONS----------------------------------------------------|; (defun c:unitLayer ( / newLayer ) ;This function runs perfectly when run from the command line but crashes when run from dialog box. (setq newLayer "1_ANSI") (foreach oldLayer '("ANSI" "_ANSI" "F.H." "1_F.H.") (renameLayer oldLayer newLayer)) (command "._purge" "la" "" "n") ) ;|------END-----DRAWING SPECIFIC RENAMING FUNCTIONS----------------------------------------------------|; (defun c:testFunction () (print "Test Function Ran") (princ) )- 11 replies
-
- dialog box
- crash
-
(and 1 more)
Tagged with: