Glen Smith Posted September 15, 2009 Posted September 15, 2009 I have a little free time and have been continuing to work on a LISP that Lee wrote for me a while back. I've made great strides today but have come up short in one place. I want to have my LISP insert three different blocks at one location, but I want them on different layers. I have the following code which works, but puts everything on whatever the current layer is. (setq rot (RTD (vla-get-rotation obj))) (setq xScale (vla-get-xscalefactor obj)) (setq yScale (vla-get-yscalefactor obj)) ;switch to kc layer (command "-insert" (nth count kclst) ipt xScale yScale rot) ;switch to mg layer (command "-insert" (nth count mglst) ipt xScale yScale rot) ;switch to wipeout layer (command "-insert" (nth count wipelst) ipt xScale yScale rot) Is there a simple way to do this? The layer should already exist in the drawing, so it should just be a matter of making it current. Thanks Glen Quote
cedwards Posted September 15, 2009 Posted September 15, 2009 try this: I'm assuming you already have the layers created. (setq rot (RTD (vla-get-rotation obj))) (setq xScale (vla-get-xscalefactor obj)) (setq yScale (vla-get-yscalefactor obj)) ;switch to kc layer (command "-layer" "s" "kc" "") (command "-insert" (nth count kclst) ipt xScale yScale rot) ;switch to mg layer (command "-layer" "s" "mg" "") (command "-insert" (nth count mglst) ipt xScale yScale rot) ;switch to wipeout layer (command "-layer" "s" "wipeout" "") (command "-insert" (nth count wipelst) ipt xScale yScale rot) Quote
ronjonp Posted September 15, 2009 Posted September 15, 2009 You could also do something like this: (will bomb if object inserted is on a locked layer, or the layer does not exist. *edit...use entmod so the layer will be automagically created if it does not exist. (setq rot (rtd (vla-get-rotation obj))) (setq xscale (vla-get-xscalefactor obj)) (setq yscale (vla-get-yscalefactor obj)) ;switch to kc layer (command "-insert" (nth count kclst) ipt xscale yscale rot) ;;(vla-put-layer (vlax-ename->vla-object (entlast)) "kc") (entmod (subst (cons 8 "kc") (assoc 8 (entget (entlast))) (entget (entlast)))) ;switch to mg layer (command "-insert" (nth count mglst) ipt xscale yscale rot) ;;(vla-put-layer (vlax-ename->vla-object (entlast)) "mg") (entmod (subst (cons 8 "mg") (assoc 8 (entget (entlast))) (entget (entlast)))) ;switch to wipeout layer (command "-insert" (nth count wipelst) ipt xscale yscale rot) ;;(vla-put-layer (vlax-ename->vla-object (entlast)) "wipeout") (entmod (subst (cons 8 "wipeout") (assoc 8 (entget (entlast))) (entget (entlast)))) 1 Quote
Glen Smith Posted September 15, 2009 Author Posted September 15, 2009 Thank you both for the quick replies , naturally I found the following link on the AfraLISP website after I posted - even though I spent a good 20 minutes looking there prior to posting. http://www.afralisp.net/lispa/lisp31.htm Cedwards, what does the ELIGHT do in this statement? Looking at the command line window implys that it should be something about reconcile, but I'm not sure what. (command "-layer" "wipeout" "ELIGHT" "") Glen Quote
cedwards Posted September 15, 2009 Posted September 15, 2009 sorry I can't type or proof read today....so see the first post since I modified it Quote
Glen Smith Posted September 15, 2009 Author Posted September 15, 2009 Ah, no problem, I thought there might be something special that typically gets done for wipeouts or something. Quote
Glen Smith Posted September 16, 2009 Author Posted September 16, 2009 Doh, Could some kind moderator move this thread to the LISP forum? I thought that I put it there but when I got home to look at it , couldn't find it. Thanks, Glen Quote
The Buzzard Posted September 16, 2009 Posted September 16, 2009 I have a little free time and have been continuing to work on a LISP that Lee wrote for me a while back. I've made great strides today but have come up short in one place. I want to have my LISP insert three different blocks at one location, but I want them on different layers. I have the following code which works, but puts everything on whatever the current layer is. (setq rot (RTD (vla-get-rotation obj))) (setq xScale (vla-get-xscalefactor obj)) (setq yScale (vla-get-yscalefactor obj)) ;switch to kc layer (command "-insert" (nth count kclst) ipt xScale yScale rot) ;switch to mg layer (command "-insert" (nth count mglst) ipt xScale yScale rot) ;switch to wipeout layer (command "-insert" (nth count wipelst) ipt xScale yScale rot) Is there a simple way to do this? The layer should already exist in the drawing, so it should just be a matter of making it current. Thanks Glen Add this function below somewhere in your program: (defun MKE_LYR (NEWLAYER CLR LT / LAY FRZ) (setq LAY (tblsearch "layer" NEWLAYER)) (if (not LAY) (command "_.layer" "_m" NEWLAYER "_c" CLR "" "_lt" LT "" "") (progn (setq FRZ (cdr (assoc 70 LAY))) (if (= FRZ 65) (progn (command "_.layer" "_t" NEWLAYER "") (command "_.layer" "_s" NEWLAYER "") ) (command "_.layer" "_s" NEWLAYER "") ) ) ) (princ) ) Then add these lines as shown before you insert block: (setq rot (RTD (vla-get-rotation obj))) (setq xScale (vla-get-xscalefactor obj)) (setq yScale (vla-get-yscalefactor obj)) ;switch to kc layer [color=red](MKE_LYR "KC" "RED" "")[/color] (command "-insert" (nth count kclst) ipt xScale yScale rot) ;switch to mg layer [color=red](MKE_LYR "MG" "GREEN" "")[/color] (command "-insert" (nth count mglst) ipt xScale yScale rot) ;switch to wipeout layer [color=red](MKE_LYR "WIPEOUT" "YELLOW" "")[/color] (command "-insert" (nth count wipelst) ipt xScale yScale rot) This will make the layer if its not there or set it if its there. Will also set color and linetype. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.