svippala Posted May 13, 2020 Posted May 13, 2020 Hi all, Can you please help me to extend line to nearest line. i am offsetting lines in between two line using offset command, afte r offsetting its create center line of two line. Please refer the snaps Thanks vr Quote
BIGAL Posted May 13, 2020 Posted May 13, 2020 (edited) Post dwg maybe 1/2 offset shorter line for inside / outside line case. Can see errors in image already. I have not done the layer linetype etc will leave that to you. ; draw line 1/2 way two lines offset shorter line. ; By Alanh (defun c:test ( / pt1 pt2 pt3 pt4 ss len1 len2 dist1 dist2 ent1 ent2) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (while (setq pt1 (getpoint "\nPick 1st point outside Enter to exit ")) (setq pt2 (getpoint pt1 "\nPick 2nd inside")) (setq ss (ssget "F" (list pt1 pt2) '((0 . "*line")))) (setq ent1 (ssname ss 0)) (setq obj (vlax-ename->vla-object ent1)) (setq pt3 (vlax-curve-getclosestpointto obj pt1)) (setq len1 (vla-get-length obj)) (setq dist1 (distance pt1 pt3)) (setq ent2 (ssname ss 1)) (setq obj (vlax-ename->vla-object ent2)) (setq pt4 (vlax-curve-getclosestpointto obj pt1)) (setq len2 (vla-get-length obj)) (setq dist2 (distance pt1 pt4)) (setq d1 (abs (/ (- dist2 dist1) 2.0))) (if (< len1 len2) (command "offset" d1 ent1 pt3 "") (command "offset" d1 ent2 pt4 "") ) ) (princ) ) (c:test) Edited May 13, 2020 by BIGAL Quote
svippala Posted May 14, 2020 Author Posted May 14, 2020 Thanks Bigal quick response please find the dwg for reference Testdwg.dwg Quote
BIGAL Posted May 14, 2020 Posted May 14, 2020 (edited) The image and the dwg are very different and a different solution all together required. It probably needs a couple of automations, the outside line which crosses the cyan plines can be done by offsetting then picking pline and using a fence option to trim the long line. Again pick two lines to get mid the pick order is direction for offset. For me before any more code suggestions need to work out how many scenario's exist. Repost dwg even with incorrect trimmed lines so can see where they are required. Please for anyone note fence must be a fraction inside pline else will trim outside line. Edited May 14, 2020 by BIGAL Quote
svippala Posted May 15, 2020 Author Posted May 15, 2020 Thanks Bigal for quick guidance.. One More Request Is there any possible to draw end less Pline options in between the two lines in the Attached above dwg. At present i am using bellow code for offset line between lines. In this code we are selecting only two line objected to offset, is there any possible to select multiple lines offset at single selection . ;; LineBetween.lsp [command name: LB] ;; To draw a Line whose endpoints are halfway Between those of two ;; User-selected Lines or Polyline [of any variety] line segments. ;; Draws Line on current Layer. ;; Accounts for Lines or Polyline line segments running generally in ;; same or opposite directions, and for 3rd dimension if applicable. ;; May draw Line between "wrong" halfway-between points if objects ;; cross, or if one crosses their apparent intersection, because routine ;; has no way to judge which possibility is expected -- try reversing ;; one object to get "right" result. ;; Result will not necessarily lie along angle bisector between selected ;; objects; will do so only if objects' relationship is symmetrical. ;; Kent Cooper, 5 March 2013 (defun C:LB ; = Line Between (/ *error* noZ svnames svvals esel ent edata etype pick s1 e1 s2 e2 int) (defun *error* (errmsg) (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break")) (princ (strcat "\nError: " errmsg)) ); if (command "_.undo" "_end") (mapcar 'setvar svnames svvals) (princ) ); defun - *error* (defun noZ (pt) (list (car pt) (cadr pt))) (setq svnames '(cmdecho aperture); = System Variable NAMES svvals (mapcar 'getvar svnames); = System Variable VALueS ); setq (mapcar 'setvar svnames (list 0 (getvar 'pickbox))) ; aperture = pickbox to prevent Osnap Center seeing wrong object (command "_.undo" "_begin") (foreach num '("1" "2") (while (not (and (setq esel (entsel (strcat "\nSelect Line/Polyline line segment #" num ": "))) (setq ent (car esel) edata (entget ent) etype (cdr (assoc 0 edata)) pick (osnap (cadr esel) "nea"); for (vlax-curve-...) later ); setq (wcmatch etype "LINE,*POLYLINE") (not (osnap pick "_cen")); if Polyline, not fit-curved or on arc segment (if (= etype "POLYLINE") (= (boole 1 4 (cdr (assoc 70 edata))) 0) T) ; not spline-curved 2D "heavy" or 3D Polyline [T for Line] ); and ); not (prompt "\nNothing, or Polyline curve, or invalid object type, selected --") ); while (set (read (strcat "s" num)); s1 or s2 [start] (if (= etype "LINE") (cdr (assoc 10 edata)); then (vlax-curve-getPointAtParam ent (fix (vlax-curve-getParamAtPoint ent pick))); else ); if ); set (set (read (strcat "e" num)); e1 or e2 [end] (if (= etype "LINE") (cdr (assoc 11 edata)); then (vlax-curve-getPointAtParam ent (1+ (fix (vlax-curve-getParamAtPoint ent pick)))); else ); if ); set ); foreach (setq int (inters (noZ s1) (noZ s2) (noZ e1) (noZ e2))); T or nil -- opposite directions (entmake (list '(0 . "LINE") (cons 10 (mapcar '/ (mapcar '+ s1 (if int e2 s2)) '(2 2 2))) (cons 11 (mapcar '/ (mapcar '+ e1 (if int s2 e2)) '(2 2 2))) ); list ); entmake (command "_.undo" "_end") (mapcar 'setvar svnames svvals) (princ) ); defun (prompt "\nType LB to draw a Line halfway Between two Lines/Polyline line segments.") Quote
BIGAL Posted May 17, 2020 Posted May 17, 2020 Your dwg is to complex for a simple solution that's why I said needs a different approach depending on the part of the dwg your trying to do this. Again post a dwg with lines drawn correct or not. 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.