Jump to content

Help! Lisp filter Hatch angle


BangVD

Recommended Posts

So how are you with making up a LISP?

 

This line will select everything in the drawing, but you can add a filter to that to get more what you want

(setq (ssget "x"))

 

This line will select all hatches

(setq ss (ssget "x" '((0 . "hatch"))))

 

This line will select all the hatches of type ANSI31

(setq ss (ssget "x" '((0 . "hatch")(2 . "ANSI31"))))

(see how I am building up ssget filter to get what I am looking for)

 

and even better this line will select all the ANSI31 hatches at an angle of 0

(setq ss (ssget "x" '((0 . "hatch")(2 . "ANSI31")(52 . 0.0))) )

If you want you can put variables instead of ANSI31 and 0.0 which can be defined earlier

 

Now a problem will happen if you don't have any hatches of that style at that angle, you might get round that with:

 

(setq hatchtype "ANSI31")
(setq hatchangle 0.0)  ;;Note angle is in radians
(if (setq ss (ssget "x" '((0 . "hatch")(2 . hatchtype)(52 . hatchangle))) )
  (progn

;;... do your stuff here with the selection set 'ss'

  ); end progn
);end if

 

  • Like 1
  • Agree 1
Link to comment
Share on other sites

Nice little functions for radian conversion.

 

(defun RtD (r) (* 180.0 (/ r pi))) ;Radian to Degree 
(defun DtR (d) (* pi (/ d 180.0))) ;Degree to Radian  


(setq hatchangle (DtR 270))

 

  • Like 2
Link to comment
Share on other sites

I am happy to receive your help.
You seem to have made it very clear above, but I don't know anything about Autolisp 😞
I am having trouble with the above problem. Can you help me create a Lisp? If it is difficult, can I fix the angle value in Lisp so I can choose a Hatch with such angles

Link to comment
Share on other sites

Yes, should be able to do that, what is your goal once you have selected all the required hatches by the way?

 

You can get LISPs to ask the use for information in a pop up box or through the command line such as asking for hatch styles or angles, or you could get it to select similar hatches by selecting one from the screen.. but what you do might depend what you want to do with the selection afterwards

Link to comment
Share on other sites

Like Steven P picking an existing object can be easiest way as you get all the information like layer, hatchname, and angle.

 

(setq ent (entget (car (entsel "\nPick a hatch"))))

(setq lay (cdr (assoc 8 ent))
hatchtype (cdr (assoc 2 ent))
hatchangle (cdr (assoc 52 ent))
)

(setq ss (ssget "x" '((0 . "hatch")(cons 2  hatchtype)(cons 52 hatchangle))) )

 

Like Steven what do you want to do once selected.

 

 

 

Edited by BIGAL
Link to comment
Share on other sites

Try this 

 

(defun c:hatpat ( / lay hatchtype hatchname hatchangle ss x )
(setq ent (entget (car (entsel "\nPick a hatch"))))

(setq lay (cdr (assoc 8 ent))
hatchtype (cdr (assoc 2 ent))
hatchangle (cdr (assoc 52 ent))
)

(setq hatchname (getreal "\nEnter hatch name"))

(setq ss (ssget "x" '((0 . "hatch")(cons 2  hatchtype)(cons 52 hatchangle))) )

(repeat (setq x (sslength ss))
(setq ent (entget (ssname ss (setq x (1- x)))))
(entmod (subst (cons 2 Hatchname) (assoc 2 ent) ent))
)

(princ)
)

 

  • Like 1
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...