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

Problem with owerdraw hatching with visual lisp

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
jdtabaress
404 Views, 7 Replies

Problem with owerdraw hatching with visual lisp

I have a command in visual lisp that make some complex drawings, and also some hatches. The problem is the hatch is being draw many times in the same object for some reason.

This are the lines i'm using to draw the hatch and to change the global variables i want to change to make different hatches. (i also will put the lisp file but it's big)

 

  (setvar "HPSEPARATE" 1)
  (setvar "HPDRAWORDER" 1)
  (command "._hatch" "s" "p" point "" "")
 
and here you can see what's the problem, there's a lot of hatches on the same box
jdtabaress_0-1714171109121.png

 

7 REPLIES 7
Message 2 of 8
Sea-Haven
in reply to: jdtabaress

Not sure about this (command "._hatch" "s" "p" p7 p9 p11 "" "") do -hatch and watch prompts when you do "s" it asks for select entities, so "P" may be previous which would explain why your getting multiples. Remove it and try.

 

NOT TESTED.

 

 

Message 3 of 8
komondormrex
in reply to: jdtabaress

if you are going to hatch every rectangle drawn by points calculated, you can define a function to hatch the last drawn entity and use it instead. see attachment.

Message 4 of 8
jdtabaress
in reply to: komondormrex

That's a really good solution, but i wonder if i can make sure that all the hatches are solid, for some reason that is not happening when i execute the function, and also the hatches are being created on the same layer than the polylines 😞

jdtabaress_0-1714671610766.png

 

Message 5 of 8
komondormrex
in reply to: jdtabaress

replace 

previous function definition

(defun last_rect_hatch nil
  (command "_-hatch" "_p" "_s" "_s" "_l" "" "")
  (entmod (append (entget (entlast)) '((8 . "40_HS_SECCIONES_SOLIDO"))))
)

with this new

(defun last_rect_hatch nil
  (command "_-hatch" "_p" "_s" "_s" "_l" "" "")
  (entmod (append (entget (entlast)) '((8 . "40_HS_SECCIONES_SOLIDO"))))
)

 

Message 6 of 8
jdtabaress
in reply to: komondormrex

That worked, but for some reason the layer keep being the layer from the last entity

Message 7 of 8
jdtabaress
in reply to: jdtabaress

Probably is because i'm currently using Gstarcad instead of Autocad, usually it's all the same.
The way i solved it is by using the function like this. I am grateful for your help.

 

 

(defun last_rect_hatch nil
  (setq current-layer (getvar "CLAYER"))
  (command "._layer" "M" "40_HS_SECCIONES_SOLIDO" "")
  (command "_-hatch" "_s" "_l" "" "_p" "_SOLID" "")
  (command "._layer" "M" current-layer "")
)
Message 8 of 8
Sea-Haven
in reply to: jdtabaress

U

(command "._layer" "M" current-layer "")

(setq current-layer (getvar "CLAYER")) ; GET at start of code

(setvar 'clayer current-layer) ; PUT at end of code

se setvar opposite of getvar

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report