BangVD Posted January 26, 2022 Posted January 26, 2022 Hello friends I have a drawing with the same Hatch but with a different tilt angle. I want to Filter the Hatchs with the angle I want, please help Hatch Angle.dwg Quote
Steven P Posted January 26, 2022 Posted January 26, 2022 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 1 1 Quote
mhupp Posted January 26, 2022 Posted January 26, 2022 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)) 2 Quote
BangVD Posted January 26, 2022 Author Posted January 26, 2022 @ 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 Quote
Steven P Posted January 26, 2022 Posted January 26, 2022 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 Quote
BIGAL Posted January 26, 2022 Posted January 26, 2022 (edited) 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 January 27, 2022 by BIGAL Quote
BangVD Posted January 27, 2022 Author Posted January 27, 2022 I want that is to change the Pattern while keeping the slant angle. so I need to filter each hatch with a different tilt angle 1 Quote
BIGAL Posted January 27, 2022 Posted January 27, 2022 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) ) 1 Quote
Recommended Posts
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.