Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Hatching Script with Plotstyle

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Nathan_Tigner
700 Views, 5 Replies

Hatching Script with Plotstyle

I have many hatches in tool palettes. The original way to create hatches in tool palettes is not working well. We are getting many errors and also don't like the process of hatching from a tool palette.

 

To get around hatching from the tool palette while still using the tool palette, I wrote a script that uses -hatch and changes all the settings for each hatch. See example below. The only problem I can't figure out is that I need to set the plotstyle for the individual hatch being used. The layer uses "black" plotstyle, but some of the hatches need to be "black 60%" or "black 80%" plotstyles. Is there a way to specify the specific hatch plotstyle in the script? And if not, is it possible to do all of this is LISP instead? Any info would be greatly appreciated. 

 

Example Script:

-layer
new
C-SITE-PVMT-PATT
color
7
C-SITE-PVMT-PATT

 

-hatch
p
cross
.5
0
la
C-SITE-PVMT-PATT
co
195
none

Labels (5)
5 REPLIES 5
Message 2 of 6
Sea-Haven
in reply to: Nathan_Tigner

Have you looked at image menu's fully controllable, these are pop menu's or could use a toolbar with say flyouts, the default image menu has 16 images, you can make your own custom dcl like a 3x3, 2x2 etc

 

SeaHaven_0-1631841650550.png

 

Message 3 of 6
Nathan_Tigner
in reply to: Sea-Haven

I did think about. Not sure exactly where to start though. I figured script or lisp would be much easier to create and load. I used a script above, and also wrote a lisp this morning that is probably not very good, but it works. Again, all I need to be able to do is set the plotstyle of the new hatch to "Black 60%" while keeping the plotstyle of the layer C-SITE-PVMT-PATT "Black". I'm close, but I just can't get it.

 

(defun c:hdcp (/ la)
(setq la (getvar "clayer"))
(if (tblsearch "layer" "C-SITE-PVMT-PATT")
(setvar "clayer" "C-SITE-PVMT-PATT")
(command

"_. LAYER" 

"T" "C-SITE-PVMT-PATT"

"M" "C-SITE-PVMT-PATT" 

"C" "7" ""

"LT" "Continuous" ""

"D" "Project Site: Pavement hatching" "*" "_yes"

"PS" "Black" "C-SITE-PVMT-PATT"

"" 

); end command function

);end if
(command "-hatch" "Properties" "cross" ".5" "0" "co" "195" "none" pause "")
(setvar "clayer" la)
(princ)

)

Message 4 of 6
ВeekeeCZ
in reply to: Nathan_Tigner

The line like this just after your -hatch line won't help?

(command "_.chprop" "_last" "" "_plotstyle" "Black 60%" "")

 

Or it's the 'cplotstyle sysvar if you want to set it prior to the command in the same manner as the 'clayer.

 
Message 5 of 6

Boom! That's it! Thank you so much!

Message 6 of 6
ВeekeeCZ
in reply to: Nathan_Tigner


@Nathan_Tigner wrote:

I did think about. Not sure exactly where to start though. I figured script or lisp would be much easier to create and load. I used a script above, and also wrote a lisp this morning that is probably not very good, but it works. Again, all I need to be able to do is set the plotstyle of the new hatch to "Black 60%" while keeping the plotstyle of the layer C-SITE-PVMT-PATT "Black". I'm close, but I just can't get it.

 

(defun c:hdcp (/ la)
(setq la (getvar "clayer"))
(if (tblsearch "layer" "C-SITE-PVMT-PATT") ; the layer exist, what happen if is frozen?
(setvar "clayer" "C-SITE-PVMT-PATT") ;
(command

"_. LAYER" 

"T" "C-SITE-PVMT-PATT" ; the layer does not exist so why you do thaw it?

"M" "C-SITE-PVMT-PATT" 

"C" "7" ""

"LT" "Continuous" ""

"D" "Project Site: Pavement hatching" "*" "_yes"

"PS" "Black" "C-SITE-PVMT-PATT"

"" 

); end command function

);end if
(command "-hatch" "Properties" "cross" ".5" "0" "co" "195" "none" pause "")
(setvar "clayer" la)
(princ)

)


 

Think of the code you wrote...

Better remove the crossed out. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report