Discussion:
convert solid to hatch
(too old to reply)
jimsmart
2005-01-06 22:45:35 UTC
Permalink
is there a way to convert multiple 2d solids to bhatches. i have searched the discussion groups and have not seen anything. any help much appreciated
Jeff Mishler
2005-01-09 02:21:49 UTC
Permalink
Here's a little routine for ya.

(defun convert2dsolids (/ 2dcoords coords count hatch obj pline space ss)
(and (setq ss (ssget '((0 . "SOLID"))))
(setq count -1)
(setq space (get_space))
(while (< (setq count (1+ count)) (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss count)))
(setq coords (vlax-get obj 'coordinates))
(setq 2dcoords (list (car coords)(cadr coords)))
(setq coords (cdr (cdr (cdr coords))))
(setq 2dcoords (append 2dcoords (list (car coords)(cadr coords))))
(setq coords (cdr (reverse (cdr (cdr (cdr coords))))))
(setq 2dcoords (append 2dcoords (list (cadr coords)(car coords))))
(setq coords (reverse coords))
(setq 2dcoords (append 2dcoords (list (car coords)(cadr coords))))
(setq pline (vlax-invoke space 'addlightweightpolyline 2dcoords))
(vla-put-closed pline :vlax-true)
(setq hatch (vlax-invoke space 'addhatch acHatchPatternTypePredefined
"SOLID" :vlax-true))
(vlax-invoke hatch 'appendouterloop (list pline))
(vla-put-color pline (vla-get-color obj))
(vla-put-color hatch (vla-get-color obj))
(vla-put-layer pline (vla-get-layer obj))
(vla-put-layer hatch (vla-get-layer obj))
(vla-delete obj)
)
)
)

(defun c:cd ()
(convert2dsolids)
(princ)
)
--
Jeff
check out www.cadvault.com
Post by jimsmart
is there a way to convert multiple 2d solids to bhatches. i have searched
the discussion groups and have not seen anything. any help much
appreciated
jimsmart
2005-01-20 23:51:32 UTC
Permalink
thanks jeff for your trouble, i tried the routine, and it returned ,; error: no function definition: GET_SPACE, my knowledge of lisp is very basic, do you know how to fix this error.

james
Jeff Mishler
2005-01-21 02:33:47 UTC
Permalink
Oops, my apologies. Load this prior to running the other.

(defun get_space ()
(if (= (getvar "cvport") 1)
(vla-get-paperspace (vla-get-activedocument (vlax-get-acad-object)))
(vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
)
)
--
Jeff
check out www.cadvault.com
Post by jimsmart
thanks jeff for your trouble, i tried the routine, and it returned ,;
error: no function definition: GET_SPACE, my knowledge of lisp is very
basic, do you know how to fix this error.
james
jimsmart
2005-01-21 05:58:41 UTC
Permalink
thankyou jeff that works great, will save our office a lot of time
PeterL4196
2005-02-14 18:41:30 UTC
Permalink
Mr. Mishler:

The original poster had success with this routine, but he knows something I do not, obviously: How do I start the routine? What do I type in at the command line to fire the thing off? I've loaded it successfully, but what now?

It may be obvious to you, but many people are not programmers, and need basic documentation.
Loading...