Jump to content

Create regions out of different layers and place them in their correspondent layer, is it possible?


Recommended Posts

Posted

Hi guys,

 

I would like to create a AutoLISP but I am still very new to it and I believe I need a lot of time, perhaps you can help?

 

I need to create create regions out of polylines and allocate these new regions into the layer of the polylines it was created from. The region command does the first step but it allocates all the new region in the same layers so I am trying to make the process quicker not do go one-by-one.

 

Could anyone help?

 

Regards,

 

 

05.PNG

Posted

Untested, but it should work...

 

(defun c:polys2regs ( / ss i poly lay reg regx)
  (if (setq ss (ssget "_:L" '((0 . "*POLYLINE") (-4 . "&=") (70 . 1))))
    (repeat (setq i (sslength ss))
      (setq poly (ssname ss (setq i (1- i))))
      (setq lay (cdr (assoc 8 (entget poly))))
      (if command-s
        (command-s "_.REGION" poly "")
        (vl-cmdf "_.REGION" poly "")
      )
      (setq reg (entlast))
      (entupd (cdr (assoc -1 (entmod (subst (cons 8 lay) (assoc 8 (setq regx (entget reg))) regx)))))
    )
  )
  (princ)
)

 

HTH.

M.R.

  • Thanks 1
Posted

That is awesome so quick and it works perfectly!

 

@marko_ribar Thanks a lot for your help!

J

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...