Jump to content

AutoLISP - Adding linetype & lineweight


rgutierrez

Recommended Posts

Hi Guys,

 

I'm creating a layer setting pull down menu, in order to migrate my cad to revit I would like to define the linewight. So far I managed to create a command with a dashed line:

 

(defun c:layA-SEC-LIH-005()

(command "layer" "m" "A-SEC-LIH-005""C" "magenta" "" "l""DASHED2" "" "")

and another one with the lineweight

 

(defun c:layA-SEC-LIH-005()

(command "layer" "m" "A-SEC-LIH-005""C" "magenta" "" "_LW" 0.10"" "")

but I haven't been able to create one that combines the 2 of them.. any help?

Cheers

Roberto

Link to comment
Share on other sites

not sure why u couldn't get it to work, but after entering the linetype, instead of exiting the command continue by giving the lineweight.

(defun c:layA-SEC-LIH-005 ()

 

(command "_-layer" "_m" "A-SEC-LIH-005" "_C" "magenta" "" "_l" "DASHED2" "_LW" "0.10" "" "" "")

)

Link to comment
Share on other sites

Hi feargt,

 

Still doesn't work, I get a prompt asking to "Enter and option" [? Make Set New Rename ON OFF Color LType LWeight Transparency MAterial Plot Freeze Thaw LOck Unlock state Description rEconcile]:

 

Doesn't work for you if you use the pull down menu?

Link to comment
Share on other sites

copy this direct on to the command line

(command "_-layer" "_m" "A-SEC-LIH-005" "_C" "magenta" "" "_l" "DASHED2" "_LW" "0.10" "" "" "")

and see does it work. it works for me.

if it does not work, press f2 and copy the text out so I can see where it stops working for you

Link to comment
Share on other sites

as requested.. btw.. thanks for helping

 

 

Command: (command "_-layer" "_m" "A-SEC-LIH-005" "_C" "magenta" "" "_l" "DASHED2" "_LW" "0.10" "" "" "")

_-layer

Current layer: "0"

Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: _m

Enter name for new layer (becomes the current layer) : A-SEC-LIH-005 Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: _C

New color [Truecolor/COlorbook] : magenta

Enter name list of layer(s) for color 6 (magenta) : Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: _l

Enter loaded linetype name or [?] : DASHED2

Enter name list of layer(s) for linetype "DASHED2" : _LW

No matching layer names found.

Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: 0.10

Invalid option keyword.

Link to comment
Share on other sites

Please pay attention that you missed to indicate the layer that will set the linetype for:

..."_L" "DASHED2" [color=red]"[font=Verdana][size=2]A-SEC-LIH-005"[/size][/font][/color]...

or

..."_L" "DASHED2" [color=red]"[font=Verdana][size=2]"[/size][/font][/color]...
Link to comment
Share on other sites

I will try tomorrow on another computer.. still doesn't work for me.. g nite

 

Command: (command "_-layer" "_m" "A-SEC-HIDDEN" "_C" "magenta" "" "_LT" "DASHED2" "_LW" "0.10" "" "" "")

_-layer

Current layer: "0"

Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: _m

Enter name for new layer (becomes the current layer) : A-SEC-HIDDEN Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: _C

New color [Truecolor/COlorbook] : magenta

Enter name list of layer(s) for color 6 (magenta) : Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: _LT

Enter loaded linetype name or [?] : DASHED2

Enter name list of layer(s) for linetype "DASHED2" : _LW

No matching layer names found.

Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: 0.10

Invalid option keyword.

; error: Function cancelled

Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: *Cancel*

Link to comment
Share on other sites

Thanks MSasu for picking that up:

(command "_-layer" "_m" "A-SEC-LIH-005" "_C" "magenta" "" "_l" "DASHED2" "" "_LW" "0.10" "" "" "")

Link to comment
Share on other sites

You may want to create a global lisp defun that just passes the variables using either entmake, command or VL eg (newlay "A- SEC-LIH-005" 5 "dashed2" 0.1) then you can use in any lisp you make.

 

(defun newlay (lay col lt thick / )
(command "_-layer" "_m" lay "_C" col "" "_l" lt "" "_LW" thick "" "" "")
)

Link to comment
Share on other sites

You may want to create a global lisp defun that just passes the variables using either entmake, command or VL eg (newlay "A- SEC-LIH-005" 5 "dashed2" 0.1) then you can use in any lisp you make.

 

(defun newlay (lay col lt thick / )
(command "_-layer" "_m" lay "_C" col "" "_l" lt "" "_LW" thick "" "" "")
)

 

BIGAL, there seems to be some issues showing up in ACAD 2015 in using the "command" function in LISP. It seems AutoCad is slowly moving away from allowing this. The better way is to use the "vl-cmdf" function, this will require the (vl-load-com) at the beginning of the LISP.

Link to comment
Share on other sites

Snownut following up I would probably use entmake or vl-addlayer now, did not want to confuse op, thats interesting perhaps create a new post 2015 & lisp ?

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...