PDA

View Full Version : How do I apply the rotation of a line to a hatch?


kristow4
2009-03-12, 09:13 PM
I am creating hatch patterns parallel to various line segments. How do I apply the rotation angle of the line to the hatch pattern? Is there a way to get the rotation angle of a line then apply it to a hatch pattern without entering it manually? Thanks.

ccowgill
2009-03-12, 11:49 PM
the way I do it is rotate my current ucs to match that of the line object. Then I hatch the area that I want hatched, then I rotate my ucs back to world.

ccowgill
2009-03-13, 01:40 PM
the way I do it is rotate my current ucs to match that of the line object. Then I hatch the area that I want hatched, then I rotate my ucs back to world.
as a suggestion for a hatch pattern that would be parallel in this instance, try ansi31 at -45 rotation.

TimSpangler
2009-03-13, 06:59 PM
This will set the hpang variable to the angle of the selected line


;; Get the line
(while (null (setq LineEnt (entsel "\n Select Line")))
(princ "\n Nothing Selected...")
)
;; Check the line
(if (/= "LINE" (cdr (assoc 0 (setq Line (entget (car LineEnt))))))
(princ "\n The selected object is not a LINE")
;; Get the line angle
(setq Lineangle (angle (cdr (assoc 10 Line))(cdr (assoc 11 Line))))
)
;; Set the angle to hatch
(setvar "HPANG" Lineangle)


Hope that helps

mweaver
2009-03-18, 03:57 AM
I am creating hatch patterns parallel to various line segments. How do I apply the rotation angle of the line to the hatch pattern? Is there a way to get the rotation angle of a line then apply it to a hatch pattern without entering it manually? Thanks.

Try this:(defun c:aht( / ss1 ss2 HatchObj LineObj )
(prompt "Select the hatch to align: ")
(setq ss1 (ssget ":S" '((0 . "HATCH"))))
(prompt "Select the line with which to align the hatch: ")
(setq ss2 (ssget ":S" '((0 . "LINE"))))
(setq
HatchObj (vlax-ename->vla-object (ssname ss1 0))
LineObj (vlax-ename->vla-object (ssname ss2 0))
)
(vla-put-patternangle HatchObj (vla-get-angle LineObj))
(vla-update HatchObj)
)