Fierce12 Posted May 14, 2013 Posted May 14, 2013 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 Quote
Tharwat Posted May 14, 2013 Posted May 14, 2013 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) ) Quote
alanjt Posted May 14, 2013 Posted May 14, 2013 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) ) Quote
alanjt Posted May 14, 2013 Posted May 14, 2013 Thanks alan! This works perfectly! It's not beautiful, but it's enough to get you started. Happy coding. Quote
Fierce12 Posted May 14, 2013 Author Posted May 14, 2013 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. Quote
alanjt Posted May 14, 2013 Posted May 14, 2013 Tharwat, be careful when changing the offset command settings. You aren't changing them back to their original setting. Quote
Tharwat Posted May 14, 2013 Posted May 14, 2013 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 . Quote
Recommended Posts
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.