Problem with owerdraw hatching with visual lisp

Problem with owerdraw hatching with visual lisp

jdtabaress
Explorer Explorer
948 Views
7 Replies
Message 1 of 8

Problem with owerdraw hatching with visual lisp

jdtabaress
Explorer
Explorer

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

 

0 Likes
Accepted solutions (2)
949 Views
7 Replies
Replies (7)
Message 2 of 8

Sea-Haven
Mentor
Mentor

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
Mentor
Mentor
Accepted solution

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
Explorer
Explorer

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

 

0 Likes
Message 5 of 8

komondormrex
Mentor
Mentor

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"))))
)

 

0 Likes
Message 6 of 8

jdtabaress
Explorer
Explorer

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

0 Likes
Message 7 of 8

jdtabaress
Explorer
Explorer
Accepted solution

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
Mentor
Mentor

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

0 Likes