convert solid to hatch

Discussion in 'AutoCAD' started by jimsmart, Jan 6, 2005.

  1. jimsmart

    jimsmart Guest

    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, Jan 6, 2005
    #1
  2. jimsmart

    Jeff Mishler Guest

    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 Mishler, Jan 9, 2005
    #2
  3. jimsmart

    jimsmart Guest

    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, Jan 20, 2005
    #3
  4. jimsmart

    Jeff Mishler Guest

    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 Mishler, Jan 21, 2005
    #4
  5. jimsmart

    jimsmart Guest

    thankyou jeff that works great, will save our office a lot of time
     
    jimsmart, Jan 21, 2005
    #5
  6. jimsmart

    PeterL4196 Guest

    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.
     
    PeterL4196, Feb 14, 2005
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.