Hi,
I'd like a lisp to quickly orient an hatch to an object, eventually choosing an angle offset (e.g. object's angle + 90°), just clicking. I neither know if I can get the angle of a polyline segment.
Sample use case are: hatching irregular paths, or tiles on irregular roof's slopes. Today I have to continuosly switch the ucs, or pick manually the object's angle and copy it in the hatch's angle:
Thank you
Solved! Go to Solution.
Solved by komondormrex. Go to Solution.
Hey Andrea,
a simple code
(defun c:align_hatch_pattern (/ prompt_ aligning_edge_ename_data picked_point picked_point_parameter
previous_parameter previous_parameter_point next_parameter next_parameter_point
aligning_angle hatch_to_align
)
;***************************************************************************************************************************
(defun round_ (float_number up / whole_number)
(setq whole_number (fix float_number))
(if up
(1+ whole_number)
whole_number
)
)
;***************************************************************************************************************************
(setq prompt_ (princ "\nPick p/line edge to align hatch to: ")
aligning_edge_ename_data (ssnamex (ssget "_:S" '((0 . "lwpolyline,line"))))
picked_point (vlax-curve-getclosestpointto (setq aligning_object (vlax-ename->vla-object (cadar aligning_edge_ename_data)))
(cadr (last (car aligning_edge_ename_data)))
)
picked_point_parameter (vlax-curve-getparamatpoint aligning_object picked_point)
previous_parameter (round_ picked_point_parameter nil)
previous_parameter_point (vlax-curve-getpointatparam aligning_object previous_parameter)
next_parameter (round_ picked_point_parameter t)
next_parameter_point (vlax-curve-getpointatparam aligning_object next_parameter)
aligning_angle (angle previous_parameter_point next_parameter_point)
prompt_ (princ "\nPick hatch to align pattern: ")
hatch_to_align (ssname (ssget "_:S" '((0 . "hatch"))) 0)
)
(vla-put-patternangle (vlax-ename->vla-object hatch_to_align) aligning_angle)
(princ)
)
Hi @komondormrex,
thank you. That works very well.
I'll study it and if I'll be able to implement the angle offset function I'll come back.
Thank you very much.
Other possible workflows to consider:
1) adjust the angle while creating hatches. <pick inside pt> <sel line to align to> <pick inside pt> <sel line to align to>...
2) select all/multiple hatches, read it's boundary and align hatch patterns to the longest segment. definitely not flawless, but very fast starting point.
Can't find what you're looking for? Ask the community or share your knowledge.