Jump to content
Fierce12

Offsetting polyline to new global width

Recommended Posts

Fierce12

I'm looking for a LISP that will allow me to offset a polyline on one layer with a global width (any varying width) to another layer (a specific layer written into the code) with a global width of 0. Please help

Share this post


Link to post
Share on other sites
Tharwat

This .. ?

 

(defun c:Test (/ *error* w l cl)
 ;;--- Tharwat 14. May. 2013 ---;;
 (defun *error* (x)
   (if cl (setvar 'clayer cl))
   (princ "\n*Cancel*")
 )
 (setq w [color=red]1.0[/color]            [color=royalblue]; Width Value[/color]
       l [color=red]"0"[/color]        [color=royalblue] ; Layer Name[/color]
 )
 (if
   (and (if (or (eq (type w) 'INT)
                (eq (type w) 'REAL)
            )
          t
          (progn
            (alert "Width Value must be either INTER , REAL Number <!>")
            nil
          )
        )
        (if (tblsearch "LAYER" l)
          t
          (progn
            (alert "Layer name is not found in drawing <!>")
            nil
          )
        )
   )
    (progn
      (setq cl (getvar 'clayer))
      (setvar 'clayer l)
      (command "_.offset" "_Layer" "_Current" w "\\" "\\" "")
      (setvar 'clayer cl)
    )
 )
 (princ)
)

Share this post


Link to post
Share on other sites
alanjt

Here's a simple sample to get you started:

 

(defun c:test (/ layer width entl dist ent pnt data)

 (setq layer "LAYER"
       width 2.
       entl  (entlast)
 )

 (initget 6)
 (if (and (setq dist (getdist "\nSpecify offset distance: "))
          (setq ent (entsel "\nSelect LWPolyline to offset: "))
          (or (eq (cdr (assoc 0 (entget (car ent)))) "LWPOLYLINE")
              (progn (princ "\nInvalid object!") nil)
          )
          (setq pnt (getpoint "\nSpecify point on side to offset: "))
     )
   (progn
     (command "_.offset" dist ent "_non" pnt "_EXIT")
     (if (not (equal entl (setq entl (entlast))))
       (entmod (subst (cons 8 layer)
                      (assoc 8 (setq data (entget entl)))
                      (subst (cons 43 width) (assoc 43 data) data)
               )
       )
     )
   )
 )
 (princ)
)

Share this post


Link to post
Share on other sites
Fierce12

Thanks alan! This works perfectly!

Share this post


Link to post
Share on other sites
alanjt
Thanks alan! This works perfectly!

 

It's not beautiful, but it's enough to get you started. Happy coding.

Share this post


Link to post
Share on other sites
Fierce12

Thanks thwart! I think you were really close! Unless I was missing something, I couldn't get the global width to change. Thanks for the quick response.

Share this post


Link to post
Share on other sites
alanjt

Tharwat, be careful when changing the offset command settings. You aren't changing them back to their original setting.

Share this post


Link to post
Share on other sites
Tharwat
Tharwat, be careful when changing the offset command settings. You aren't changing them back to their original setting.

Entirely correct , Thank you Alan for your for precious comments .:thumbsup:

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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