Jump to content

Recommended Posts

Posted (edited)

Here's a useful Lee.Mac Power.tool

 

 

TotalLengthPolylineV1-0.lsp

 

Edited by SLW210
Removed Code Not placed in Code Tags as already attached the file!!!
  • Like 1
  • Dislike 1
Posted (edited)

I did something for water pipes or electric cables in a road, it just allows you to follow line segments, with a predefined offset. I am not sure though in your last bit of Video if you want to enter the length of the last leg, can you clarify that. The code I have draws a full last length.

 

@ScottMC not sure that overall length is required. Just a ps did you mean to post the actual code  as you have the lisp file to download.

Edited by BIGAL
  • Like 1
Posted

Thank you for your answers. The Lisp code you described might be useful, but as you said, when traversing areas like walls or columns, it offsets the line by 6 units, and if there's a pre-drawn, offset line, it follows it all the way to the end. Could you share your code? @BÜYÜK

Posted (edited)

Trying to find it again.

 

Give this a try. You pick points in sequence it will draw offsets, make sure you press Enter to finish picking points as it will fillet all the offset segments.  offset sides pline.lsp

Edited by BIGAL
  • Like 2
Posted (edited)
1 hour ago, hardwell3458 said:

Thank you, but it didn't work in this form.

Are you using a localized version of AutoCAD? Try this option.

; By Alan H AUG 2019 / modification
; offset sides pline.lsp - original
; draw offsets from points for random shape object making pline
; https://www.cadtutor.net/forum/topic/98954-smart-offset-lisp/
; Added characters (_) for localized versions of Autocad.
; You select the points sequentially, and the program draws the offsets. Right-right-down / Left-left-up
; Be sure to press Enter or rmb (right mouse button) to complete the selection of points,
; this way, the program will smooth out all the offset segments (i.e. combine them into a polyline). 
; added memorization of the last offset distance selection
; Added backlight for selecting [Right/Left], [Swap sides]

(defun c:ploffs-m (/ offdir offd x pt1 pt2 pt3 oldsnap ssp)
  (defun drawline (/ ang pt3 obj)
    (setq ang (angle pt1 pt2))
    (if (= offdir "L")
      (setq pt3 (polar pt2 (+ ang (/ pi 2.0)) 10))
      (setq pt3 (polar pt2 (- ang (/ pi 2.0)) 10))
    )
    (setvar 'osmode 0)
    (command "_.line" pt1 pt2 "")
    (setq obj (entlast))
    (command "_.offset" offd obj pt3 "")
    (setq ssp (ssadd (entlast) ssp))
    (command "_.erase" obj "")
    (setq pt1 pt2)
  )

  (defun swapr-l (/)
    (if (= (strcase offdir) "L")
      (setq offdir "R")
      (setq offdir "L")
    )
    (setvar 'osmode oldsnap)
    (setq pt1 (getpoint "\nPick  next point"))
    (setq pt2 (getpoint "\nPick  next point"))
    (drawline)
  )

; add side pick
  (setq oldsnap (getvar 'osmode))
  (setq ssp nil)

  (initget 6 "R L")
  ; (setq offdir (strcase (getstring "Right or Left")))
(setq offdir (strcase (getstring "[Right/Left]")))
;; --- remember last offset distance ---
  (if (not (boundp '*lastOffD*))
    (setq *lastOffD*
      (if (getenv "MY_LAST_OFFD")
        (atof (getenv "MY_LAST_OFFD"))
        10.0  ; (offset distance By default)
      )
    )
  )

  (setq offd (getreal (strcat "\nEnter offset distance <" (rtos *lastOffD* 2 4) ">: ")))
  (if (null offd)
    (setq offd *lastOffD*)
    (progn
      (setq *lastOffD* offd)
      (setenv "MY_LAST_OFFD" (rtos offd 2 8))
    )
  )
  ;; --- /remember last offset distance ---

  (setq pt1 (getpoint "pick 1st point"))
  (setq ssp (ssadd))

  (initget 6 "1 2 3 4 5 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x y z")
  (while (setq pt2 (getpoint "\nPick  next point or [Swap sides]:<"))
    (cond
      ((= (type pt2) 'LIST) (drawline))
      ((= (type pt2) 'str) (swapr-l))  ; also calls drawlines
      ((= pt2 nil) (quit))
    )
    (setvar 'osmode oldsnap)
    (initget 6 "Swap")
  )

  (setq x 0)
  (repeat (- (sslength ssp) 1)
    (setvar 'filletrad 0)
    (command "_.fillet" (ssname ssp x) (ssname ssp (1+ x)))
    (setq x (1+ x))
  )

  (setq x 0)
  (command "_.pedit" (entlast) "_Y" "_J") ; if "Join" doesn't work, try the line below without the "_Y"
 ;(command "_.pedit" (entlast) "_J")
  (repeat (- (sslength ssp) 1)
    (command (ssname ssp x))
    (setq x (1+ x))
  )
  (command "" "")
  (princ)
)

 

ploffs-m.gif

Edited by Nikon

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