Rob-GB Posted July 13, 2009 Posted July 13, 2009 I would like to get my lisp to use a different linetype for some hidden lines. Possibly will have to change layers too! (command "-linetype" "_l" "DASHED2" "acad.lin" "") This bit of code is borrowed from a post by ASMI, one problem is that I do not understand what all this "_l" "DASHED2" "acad.lin" really means yet! Any thoughts or prods in the right direction gratefully received. Rob. Quote
MSasu Posted July 13, 2009 Posted July 13, 2009 The “-“ in front of command name is forcing the LINETYPE to work in command-line mode (that it, no dialog box and no user confirmation); to understand the other arguments may test the LINETYPE in this mode. “L” = ask to load a line definition to drawing, “DASHED2” = is the line definition to be loaded (replace with desired type), “ACAD.LIN” = built-in database with line definitions (can be a user data-base instead), “” = final to get command finished (is repetitive). The “_” is added to ensure that this code will work in localized versions of AutoCAD too. Hope that this clarifies the issue. Regards Quote
Lee Mac Posted July 13, 2009 Posted July 13, 2009 Another way to load a Linetype is to use vla-load. Quote
Rob-GB Posted July 13, 2009 Author Posted July 13, 2009 Thanks for clarifying that msasu it will indeed help. Lee there are a lot of those vla- commands floating about but I'm really not sure of all the basic lisp language yet.:wink: My casement drawing code has moved on to have both side and plan views of the casement and the drip groove took me a days research and an hour or so fiddling about to get the code to work. One small victory at a time and I will conquer the code . Rob. Quote
Rob-GB Posted July 13, 2009 Author Posted July 13, 2009 Stuck again!! Sorry. (setq OLDTYPE (getvar "LINETYPE") ) (command "_linetype" "_l" "ACAD_ISO03W100" "Acad.lin" "" ) (command "_.PLINE" F25 F26 "" ;to be hidden dashed line linetype ACAD_ISO03W100 ) (command "_.PLINE" F33 F34 "" ;to be hidden dashed line ) (command "_.PLINE" F27 F38 "" ;to be hidden dashed line ) (command "_.PLINE" F39 F40 "" ;to be hidden dashed line ) (setvar "LINETYPE" OLDTYPE) This what I have so far. Am trying to store existing linetype then draw the few required lines in the new linetype, then restore old the old one. Not having a very good day with having to run errands and deal with phone calls, so it's probably something simple that escapes me. Quote
The Buzzard Posted July 13, 2009 Posted July 13, 2009 Stuck again!! Sorry. (setq OLDTYPE (getvar "LINETYPE") ) (command "_linetype" "_l" "ACAD_ISO03W100" "Acad.lin" "" ) (command "_.PLINE" F25 F26 "" ;to be hidden dashed line linetype ACAD_ISO03W100 ) (command "_.PLINE" F33 F34 "" ;to be hidden dashed line ) (command "_.PLINE" F27 F38 "" ;to be hidden dashed line ) (command "_.PLINE" F39 F40 "" ;to be hidden dashed line ) (setvar "LINETYPE" OLDTYPE) This what I have so far. Am trying to store existing linetype then draw the few required lines in the new linetype, then restore old the old one. Not having a very good day with having to run errands and deal with phone calls, so it's probably something simple that escapes me. Hey Rob, Try this, Place this function somewhere in your program. ;;; Layer Function - Set Layer & Linetype. ;Function Description (defun SLL (NLAY CLR LT / LAY FRZ) ;Define function, Declare local variables and arguments (setq LAY (tblsearch "layer" NLAY)) ;Search drawing to find layer, Note: (NOT USED) (if ;If the following returns true (not LAY) ;Layer not in drawing (command "_.layer" "m" NLAY "c" CLR "" "lt" LT "" "") ;Layer command ~ make new layer with color and linetype (progn ;Then do the following (setq FRZ (cdr (assoc 70 LAY))) ;Variable FRZ is frozen layer (if (= FRZ 65) ;Layer frozen from last edit (progn ;Then do the following (command "_.layer" "t" NLAY "") ;Thaw new layer if frozen (command "_.layer" "s" NLAY "")) ;Set new layer (command "_.layer" "s" NLAY "")))) ;Set new layer ) ;End define function Place this when you want to add the layer. It will create the layer, color & linetype if it does not exist or Set it if it does exist. (SLL "Mylayer" "Mycolor" "MyLinetype") ;Go to SLL Layer Function, Set Layer, Color & Linetype Note: THe linetype definition needs to be in the ACAD.lin file for the linetype to be set. Any further help just ask. The Buzzard Quote
The Buzzard Posted July 13, 2009 Posted July 13, 2009 Here you can demo the program to see how it works. Load this function and type HIDLAY. It will create a layer called Mylayer with a red color and a hidden linetype. (defun C:HIDLAY () (SLL "Mylayer" "1" "HIDDEN") ;Go to SLL Layer Function (princ) ) ;;; Layer Function - Set Layer & Linetype. ;Function Description (defun SLL (NLAY CLR LT / LAY FRZ) ;Define function, Declare local variables and arguments (setq LAY (tblsearch "layer" NLAY)) ;Search drawing to find layer, Note: (NOT USED) (if ;If the following returns true (not LAY) ;Layer not in drawing (command "_.layer" "m" NLAY "c" CLR "" "lt" LT "" "") ;Layer command ~ make new layer with color and linetype (progn ;Then do the following (setq FRZ (cdr (assoc 70 LAY))) ;Variable FRZ is frozen layer (if (= FRZ 65) ;Layer frozen from last edit (progn ;Then do the following (command "_.layer" "t" NLAY "") ;Thaw new layer if frozen (command "_.layer" "s" NLAY "")) ;Set new layer (command "_.layer" "s" NLAY "")))) ;Set new layer ) ;End define function Quote
Rob-GB Posted July 13, 2009 Author Posted July 13, 2009 Thanks Buzzard. Just to get my mindset right in this bit all I have to do is alter; (SLL "Mylayer" "Mycolor" "MyLinetype") exchange Mylayer to the name of the layer I want Mycolor to say 63 for a light brown color & Mylinetype to Acad_ISO03W100 If this is true then by jove I think I've got it! It just dawned on me that I may have to do several defun's like this to organise layers and line types for frames, sashes and fanlights etc as well! If so the best place for them will be just before any ._line or ._pline commands: grouped as with the user input commands? Regards Rob. Quote
The Buzzard Posted July 13, 2009 Posted July 13, 2009 Thanks Buzzard.Just to get my mindset right in this bit all I have to do is alter; (SLL "Mylayer" "Mycolor" "MyLinetype") exchange Mylayer to the name of the layer I want Mycolor to say 63 for a light brown color & Mylinetype to Acad_ISO03W100 If this is true then by jove I think I've got it! It just dawned on me that I may have to do several defun's like this to organise layers and line types for frames, sashes and fanlights etc as well! If so the best place for them will be just before any ._line or ._pline commands: grouped as with the user input commands? Regards Rob. Exactly! Here is the same routine that make the new layer and restores the old layer when done. Just want you to see different possibilities. (defun C:HIDLAY () ;Define function (setq OLDLAY (getvar "CLAYER")) ;Save current layer to old layer (SLL "Mylayer" "1" "HIDDEN") ;Go to SLL Layer Function (setvar "CLAYER" OLDLAY) ;Restore old layer (princ) ;Exit quietly ) ;End define function ;;; Layer Function - Set Layer & Linetype. ;Function Description (defun SLL (NLAY CLR LT / LAY FRZ) ;Define function, Declare local variables and arguments (setq LAY (tblsearch "layer" NLAY)) ;Search drawing to find layer, Note: (NOT USED) (if ;If the following returns true (not LAY) ;Layer not in drawing (command "_.layer" "m" NLAY "c" CLR "" "lt" LT "" "") ;Layer command ~ make new layer with color and linetype (progn ;Then do the following (setq FRZ (cdr (assoc 70 LAY))) ;Variable FRZ is frozen layer (if (= FRZ 65) ;Layer frozen from last edit (progn ;Then do the following (command "_.layer" "t" NLAY "") ;Thaw new layer if frozen (command "_.layer" "s" NLAY "")) ;Set new layer (command "_.layer" "s" NLAY "")))) ;Set new layer ) ;End define function Quote
Rob-GB Posted July 13, 2009 Author Posted July 13, 2009 Thanks Buzzard, I think your christian name suits you well. Phone is being a daymare today so whilst trying to reply I got hung up by the mouth with a possible client, really, don't they realise I have more important stuff to do than explain in terms a three year old would understand that plus tax is plus tax (vat in the uk) Just had another 17 minutes on the phone while writing this:roll: Quote
The Buzzard Posted July 13, 2009 Posted July 13, 2009 Thanks Buzzard, I think your christian name suits you well.Phone is being a daymare today so whilst trying to reply I got hung up by the mouth with a possible client, really, don't they realise I have more important stuff to do than explain in terms a three year old would understand that plus tax is plus tax (vat in the uk) Just had another 17 minutes on the phone while writing this:roll: No problem Rob, Always glad to help. Do not let the possible clients slip thru the cracks. Priorities first. Quote
The Buzzard Posted July 13, 2009 Posted July 13, 2009 Originally Posted by Rob-GB It just dawned on me that I may have to do several defun's like this to organise layers and line types for frames, sashes and fanlights etc as well! If so the best place for them will be just before any ._line or ._pline commands: grouped as with the user input commands? Regards Rob. Rob, I realized you might have thought you need to make a function for everytime you want to set a layer. Not so. I just want to clarify. Here in this example two different layers are created with two different linetypes and two different colors. Just call the layer function before the line you want to change. Here is a better example. Function Syntax: LINLAY (defun C:LINLAY () ;Define function (setq OLDLAY (getvar "CLAYER")) ;Save current layer to old layer (command "_.ltscale" 20) ;Set line scale (setq PT01 (list 0.0 0.0 0.0)) ;PT01 Coord (setq PT02 (list 25.0 25.0 0.0)) ;PT02 Coord (setq PT03 (list 25.25 25.50 0.0)) ;PT03 Coord (setq PT04 (list 50.25 60.0 0.0)) ;PT04 Coord (SLL "HIDDEN" "1" "HIDDEN") ;Go to SLL Layer Function (command "_.line" PT01 PT02 "") ;Line command (SLL "CONTINUOUS" "5" "CONTINUOUS") ;Go to SLL Layer Function (command "_.line" PT03 PT04 "") ;Line command (setvar "CLAYER" OLDLAY) ;Restore old layer (princ) ;Exit quietly ) ;End define function ;;; Layer Function - Set Layer & Linetype. ;Function Description (defun SLL (NLAY CLR LT / LAY FRZ) ;Define function, Declare local variables and arguments (setq LAY (tblsearch "layer" NLAY)) ;Search drawing to find layer, Note: (NOT USED) (if ;If the following returns true (not LAY) ;Layer not in drawing (command "_.layer" "m" NLAY "c" CLR "" "lt" LT "" "") ;Layer command ~ make new layer with color and linetype (progn ;Then do the following (setq FRZ (cdr (assoc 70 LAY))) ;Variable FRZ is frozen layer (if (= FRZ 65) ;Layer frozen from last edit (progn ;Then do the following (command "_.layer" "t" NLAY "") ;Thaw new layer if frozen (command "_.layer" "s" NLAY "")) ;Set new layer (command "_.layer" "s" NLAY "")))) ;Set new layer ) ;End define function 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.