Jump to content

Polyline to Block


John E Green

Recommended Posts

Hi,

 

I hope someone can help me!!! I have been searching high and low for an Autolisp routine to convert a polyline to a block, I found some that work but what I want to do is use the boundry command to create a ployline round a room, then convert the polyline to a block. I can create the polyline fine via Autolisp and I can convert an existing polyline to a block, but when I try and put the two together it goes all wrong.

 

Any help or pointer would be very helpful.

 

John

Link to comment
Share on other sites

This should convert selected objects to blocks:

 

(defun c:obj2blk (/ BNME ENT I PT SS SUB)
 ;; Lee Mac  ~  11.02.10

 (cond (  (not (setq ss (ssget '((0 . "~VIEWPORT"))))))

       (  (while
            (progn
              (setq bNme (getstring t "\nSpecify Block Name: "))

              (cond (  (not (snvalid bNme))
                       (princ "\n** Invalid Block Name **"))

                    (  (tblsearch "BLOCK" bNme)
                       (princ "\n** Block Already Exists **"))))))

       (  (not (setq i -1 pt (getpoint "\nSpecify Base Point: "))))

       (t (entmake (list (cons 0 "BLOCK") (cons 10 pt) (cons 2 bNme) (cons 70 0)))

          (while (setq ent (ssname ss (setq i (1+ i))))             
            (entmake (entget ent))
            
            (and (= 1 (cdr (assoc 66 (entget (setq sub ent)))))
                 (while (not (eq "SEQEND" (cdr (assoc 0 (entget (setq sub (entnext sub)))))))
                   (entmake (entget sub)))
                 (entmake (entget sub)))
            
            (entdel ent))

          (entmake (list (cons 0 "ENDBLK") (cons 8 "0")))
          (entmake (list (cons 0 "INSERT") (cons 2 bNme) (cons 10 pt)))))

 (princ))

Link to comment
Share on other sites

Hi Lee,

 

Thanks for such a prompt reply, I think I can see where I was going wrong now. I'll try you routine later.

 

Many thanks

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...