CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz] ARKANCE | CONTACT - CZ | SK | EN | DE
RSS channel - CAD tips RSS tips
RSS discussions

Discussion Discussion forum

?
CAD discussions, advices, exchange of experience

CAD Forum - Homepage CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.

Please abide by the rules of this forum.
This is a peer-to-peer forum. The forum doesn't replace the official direct technical support provided by ARKANCE for its customers.
How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic ClosedLisp - layer, command

 Post Reply Post Reply
Author
Kajito View Drop Down
Senior Member
Senior Member


Joined: 29.Oct.2008
Location: Ireland
Status: Offline
Points: 130
Direct Link To This Post Topic: Lisp - layer, command
    Posted: 14.Nov.2013 at 22:56

Hi guys,


I'd like to ask you for help with following. I'd say it is a fairly easy task if you know basics of LISP progamming ( I don't unfortunately :). I've been trying to search on the net but couldnt find any answer somehow.

I need a lisp routine that would set a layer (say Hatch1), and start the hatch command. As "simple" as that ;).

I've changed job recently and this company is using to different layers for hatch (hatch and shade). Therefore solutions like flay or new command with associated shortcut or alias will not work as it will alwys set the same layer.

Thank you very much for any solutions and suggestions.

Kajito

Back to Top
John Connor View Drop Down
Senior Member
Senior Member


Joined: 01.Feb.2011
Location: United States
Using: AutoCAD 2018
Status: Offline
Points: 7175
Direct Link To This Post Posted: 15.Nov.2013 at 12:24
This will set the layer.  As for the Hatch command itself is there any other criteria that has to be met?  Ex. - pattern to be used.
(defun c:test ()
(command "_.layer" "_set" "hatch1" "")
(princ)
)


Edited by John Connor - 15.Nov.2013 at 12:35
"Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."

<<AutoCAD 2015>>

Back to Top
John Connor View Drop Down
Senior Member
Senior Member


Joined: 01.Feb.2011
Location: United States
Using: AutoCAD 2018
Status: Offline
Points: 7175
Direct Link To This Post Posted: 15.Nov.2013 at 12:40
Example of a hatch lisp routine (by GHarvey) that sets the layer and calls out which hatch pattern will be used and specifies the hatch pattern will be applied to an object.
(defun c:iso ()
 (command "-layer" "S" "hatch" "")
 (command "-hatch" "Properties" "ANSI37" 6 0 pause)
 (command "-layer" "S" "object" "")
 (princ)
 )


"Humans have a strength that cannot be measured. This is John Connor. If you are reading this, you are the resistance."

<<AutoCAD 2015>>

Back to Top
Kent Cooper View Drop Down
Senior Member
Senior Member


Joined: 12.Mar.2013
Location: United States
Using: AutoCAD2020, 2023
Status: Offline
Points: 686
Direct Link To This Post Posted: 15.Nov.2013 at 14:43
I would recommend using the Make option rather than Set, because if the Layer does not exist in the drawing, it won't be able to be set current.  The Make option will also make it current, and will turn it on if it's off.  And I would recommend including a Thawing of the Layer before Making or Setting it, because if it's frozen, it won't be able to be made current; the Thaw option won't care whether the Layer exists yet or not.
 
(defun C:HATCH1 ()
  (command
    "_.layer" "_thaw" "HATCH1" "_make" "HATCH1" ""
    "_.hatch" ; or "_.bhatch" if preferred
  )
)
 
That will leave you in the Hatch command, to complete as you like.
 
If you want a particular pattern, you can build that into the Hatch command, or you can first use (setvar 'hpname "WHATEVER") and make it the current pattern before calling up the command.  The same approach can also be used for other Hatch options, such as the scale and angle.
Back to Top
Kajito View Drop Down
Senior Member
Senior Member


Joined: 29.Oct.2008
Location: Ireland
Status: Offline
Points: 130
Direct Link To This Post Posted: 16.Nov.2013 at 19:05
Thank you guys soo much for your help. Exactly what I needed.
Back to Top

Related CAD tips:


 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



This page was generated in 0,055 seconds.