Jump to content

Recommended Posts

Posted

Hi all,

 

I have a lisp to create double yellow lines for road markings. There are 2 options in the lisp. 1: Select a line to offset to create the yellow lines or 2: draw along a line to offset to create the lines. I usually draw closed polylines to represent a section of footpath and so for the selected option I would like to select two points between which the line is offset rather than the entire closed polyline. Can anyone help me with this?

 

(defun C:RRM008 (/ ang coords elist midp offsetted offsetted1 ofpt p1 p2 p3 pline side SUCE SUOM SUSM SUAB SUAD SUCL SUCR)
(setq SUCE (getvar "cmdecho"))
 (setq SUOM (getvar "orthomode"))
 (setq SUSM (getvar "osmode"))
 (setq SUAB (getvar "angbase"))
 (setq SUAD (getvar "angdir"))
 (setq SUCL (getvar "clayer"))
 (setq SUCR (getvar "cecolor"))
;(command "_.-layer" "_N" "CCC_LAYOUT_Proposed_Road_Lining_Yellow_RRM008" "_C" "2" "CCC_LAYOUT_Proposed_Road_Lining_Yellow_RRM008" "" )

(setq vl1 (list
	(cons 0 "LAYER")		;Name of entity
	(cons 100 "AcDbSymbolTableRecord")					;Open Records
	(cons 100 "AcDbLayerTableRecord")					;Locate Layer Table
	(cons 2 "CCC_LAYOUT_Proposed_Road_Lining_Yellow_RRM008")		;Name of Layer
	(cons 6 "Continuous")						;Linetype
	(cons 62 2)							;colour = light grey
	(cons 70 0)							;state
	(cons 290 1)							;1=plot, 0=Don't plot
		)							;End of entity list
	)
	(entmake vl1)

(setvar "clayer" "CCC_LAYOUT_Proposed_Road_Lining_Yellow_RRM008")  
(command "._-linetype"  "s"  "bylayer" "")
(setvar "cecolor" "1")

(initget "D S")
(setq option (getkword "\nChoose Draw line or Select line method: [D/S]: "))
(cond     ((= option "D")(yellow_draw_01))
((= option "S")(yellow_select_01))
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun yellow_select_01 ()
(setq pline(entsel "\nSelect a kerb line: "))
(yellow_resume)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun yellow_draw_01 ()
(princ "\nDraw a kerb line: ")
(setvar "cecolor" "1")  
(command "._pline")
(while (= 1 (logand 1 (getvar "cmdactive")))
(command pause))
(setq pline (entlast)
elist (entget pline)
)
(setvar "cecolor" "Bylayer") 
(yellow_resume)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun yellow_resume ()
(setq side(getpoint "\nPick an offset side: "))
(command "._offset" 0.3 pline side "")
(setq offsetted (entlast)
elist (entget offsetted)
)
(entmod elist)
(command "._pedit" offsetted "_W" 0.1 "")
(setq coords (vl-remove-if (function not)
(mapcar (function (lambda (x)
(if (= 10 (car x))(cdr x))))
elist))
)
(setq p2 (car coords)
midp (mapcar (function (lambda( a b)(/ (+ a b) 2)))
p1 p2)
)
(command "_change" offsetted ""  "p" "Layer" "CCC_LAYOUT_Proposed_Road_Lining_Yellow_RRM008" "color" "Bylayer" "")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(command "._offset" 0.5 pline side "")
(setq offsetted1 (entlast)
elist (entget offsetted1)
)
(entmod elist)
(command "._pedit" offsetted1 "_W" 0.1 "")
(setq coords (vl-remove-if (function not)
(mapcar (function (lambda (x)
(if (= 10 (car x))(cdr x))))
elist))
)
(setq p2 (car coords)
midp (mapcar (function (lambda( a b)(/ (+ a b) 2)))
p1 p2)
)

(command "_change" offsetted1 ""  "p" "Layer" "CCC_LAYOUT_Proposed_Road_Lining_Yellow_RRM008" "color" "Bylayer" "")

(cond     ((= option "D")(command "_erase" pline "" ))
)

 (setvar "cmdecho"   SUCE)
 (setvar "orthomode" SUOM)
 (setvar "osmode"    SUSM)
 (setvar "angbase"   SUAB)
 (setvar "angdir"    SUAD)
 (setvar "clayer"    SUCL)
 (setvar "cecolor"    SUCR)
(princ) 
)

Posted

Try placing

(load "OffsetSectionV1-1.lsp")

early in the code and calling it with

(c:offsec)

Posted

OK. Tombu. Thanks.

Leemac, what setting do I change to only offset on one side?

Posted

Can someone help with me with this, maybe Leemac? I am trying to adapt Leemac's OffSetSection to offset to just one side but I need to introduce a part to ask which side but I am failing badly at it.

Posted

Since vla-offset doesn't work the same way as the OFFSET command it may be tricky to modify the way you want it. Isn't deleting the side you don't want about as easy as selecting the side you want? That way it would work for when you need it offset to both sides as well.

Posted

I'm sure you mean something like this. Someone could add some code to let you choose which side to offset on, but I don't have time

;;------------------=={ Offset LWPolyline Section }==-------------------;;
;;                                                                      ;;
;;  This program prompts the user to specify an offset distance and to  ;;
;;  select an LWPolyline. The user is then prompted to specify two      ;;
;;  points on the LWPolyline enclosing the section to be offset. The    ;;
;;  progam will proceed to offset all segments between the two given    ;;
;;  points to both sides by the specified distance.                     ;;
;;                                                                      ;;
;;  The program is compatible with LWPolylines of constant or varying   ;;
;;  width, with straight and/or arc segments, and defined in any UCS    ;;
;;  construction plane.                                                 ;;
;;----------------------------------------------------------------------;;
;;  Author:  Lee Mac, Copyright © 2013  -  www.lee-mac.com              ;;
;;----------------------------------------------------------------------;;
;;  Version 1.0    -    27-12-2012                                      ;;
;;                                                                      ;;
;;  First release.                                                      ;;
;;----------------------------------------------------------------------;;
;;  Version 1.1    -    05-04-2013                                      ;;
;;                                                                      ;;
;;  Fixed bug when offsetting polyline arc segments.                    ;;
;;----------------------------------------------------------------------;;

;;Slightly edited By: CB (Sorry Lee-Mac)

(defun c:offsec ( / d e h l m n o p q w x z )
   (if (null *off*)
       (setq *off* 1.0)
   )
   (initget 6)
   (if (setq d (getdist (strcat "\nSpecify Offset <" (rtos *off*) ">: ")))
       (setq *off* d)
       (setq d *off*)
   )
   (while
       (progn (setvar 'errno 0) (setq e (car (entsel "\nSelect LWPolyline: ")))
           (cond
               (   (= 7 (getvar 'errno))
                   (princ "\nMissed, try again.")
               )
               (   (null e) nil)
               (   (/= "LWPOLYLINE" (cdr (assoc 0 (entget e))))
                   (princ "\nObject is not an LWPolyline.")
               )
               (   (setq p (getpoint "\nSpecify 1st Point: "))
                   (setq p (vlax-curve-getclosestpointto e (trans p 1 0)))
                   (while
                       (and
                           (setq  q (getpoint (trans p 0 1) "\nSpecify 2nd Point: "))
                           (equal p (setq q (vlax-curve-getclosestpointto e (trans q 1 0))) 1e-
                       )
                       (princ "\nPoints must be distinct.")
                   )
                   (if q
                       (progn
                           (if (> (setq m (vlax-curve-getparamatpoint e p))
                                  (setq n (vlax-curve-getparamatpoint e q))
                               )
                               (mapcar 'set '(m n p q) (list n m q p))
                           )
                           (setq e (entget e)
                                 h (reverse (member (assoc 39 e) (reverse e)))
                                 h (subst (cons 70 (logand (cdr (assoc 70 h)) (~ 1))) (assoc 70 h) h)
                                 l (LM:LWVertices e)
                                 z (assoc 210 e)
                           )
                           (repeat (fix m)
                               (setq l (cdr l))
                           )
                           (if (not (equal m (fix m) 1e-)
                               (setq x (car l)
                                     w (cdr (assoc 40 x))
                                     l
                                   (cons
                                       (list
                                           (cons  10 (trans p 0 (cdr z)))
                                           (cons  40 (+ w (* (- m (fix m)) (- (cdr (assoc 41 x)) w))))
                                           (assoc 41 x)
                                           (cons  42
                                               (tan
                                                   (*  (- (min n (1+ (fix m))) m)
                                                       (atan (cdr (assoc 42 x)))
                                                   )
                                               )
                                           )
                                       )
                                       (cdr l)
                                   )
                               )
                           )
                           (setq l (reverse l))
                           (repeat (+ (length l) (fix m) (- (fix n)) -1)
                               (setq l (cdr l))
                           )
                           (if (not (equal n (fix n) 1e-)
                               (setq x (car l)
                                     w (cdr (assoc 40 x))
                                     l
                                   (vl-list*
                                       (list
                                           (cons 10 (trans q 0 (cdr z)))
                                          '(40 . 0.0)
                                          '(41 . 0.0)
                                          '(42 . 0.0)
                                       )
                                       (list
                                           (assoc 10 x)
                                           (assoc 40 x)
                                           (cons  41
                                               (+ w
                                                   (*  (/ (- n (max m (fix n))) (- (1+ (fix n)) (max m (fix n))))
                                                       (- (cdr (assoc 41 x)) w)
                                                   )
                                               )
                                           )
                                           (cons  42
                                               (tan
                                                   (*  (if (< (fix n) m) 1.0 (- n (fix n)))
                                                       (atan (cdr (assoc 42 x)))
                                                   )
                                               )
                                           )
                                       )
                                       (cdr l)
                                   )
                               )
                           )
                           (setq o
                               (vlax-ename->vla-object
                                   (entmakex (append h (apply 'append (reverse l)) (list z)))
                               )
                           )
                           (vl-catch-all-apply 'vla-offset (list o d))
                           (vl-catch-all-apply 'vla-offset (list o (* 2 d)))
                           (vla-delete o)
                       )
                   )
               )
           )
       )
   )
   (princ)
)

;; Tangent  -  Lee Mac
;; Args: x - real

(defun tan ( x )
   (if (not (equal 0.0 (cos x) 1e-)
       (/ (sin x) (cos x))
   )
)

;; LW Vertices  -  Lee Mac
;; Returns a list of lists in which each sublist describes the position,
;; starting width, ending width and bulge of a vertex of an LWPolyline

(defun LM:LWVertices ( e )
   (if (setq e (member (assoc 10 e) e))
       (cons
           (list
               (assoc 10 e)
               (assoc 40 e)
               (assoc 41 e)
               (assoc 42 e)
           )
           (LM:LWVertices (cdr e))
       )
   )
)

;;----------------------------------------------------------------------;;

(vl-load-com)
(princ
   (strcat
       "\n:: OffsetSection.lsp | Version 1.1 | \\U+00A9 Lee Mac "
       (menucmd "m=$(edtime,0,yyyy)")
       " www.lee-mac.com ::"
       "\n:: Type \"offsec\" to Invoke ::"
   )
)
(princ)

;;----------------------------------------------------------------------;;
;;                             End of File                              ;;
;;----------------------------------------------------------------------;;

Posted

And I don't like changing Lee-Mac's code, since he would do better.

Posted (edited)
And I don't like changing Lee-Mac's code, since he would do better.

and all those same reasons, but you made me do it:

 ;|------------------=={ Offset LWPolyline Section }==-------------------

 This program prompts the user to specify an offset distance and to
 select an LWPolyline. The user is then prompted to specify two
 points on the LWPolyline enclosing the section to be offset. The
 progam will proceed to offset all segments between the two given
 points to both sides by the specified distance.

 The program is compatible with LWPolylines of constant or varying
 width, with straight and/or arc segments, and defined in any UCS
 construction plane.
----------------------------------------------------------------------
 Author:  Lee Mac, Copyright © 2013  -  www.lee-mac.com
----------------------------------------------------------------------
 Version 1.0    -    27-12-2012

 First release.
----------------------------------------------------------------------
 Version 1.1    -    05-04-2013

 Fixed bug when offsetting polyline arc segments.
----------------------------------------------------------------------
 Version 1.2    -    06-09-2015

 Added prompt to select side to offset.  Tom Beauford
----------------------------------------------------------------------|;

(defun c:offsec ( / d e h l m n o p q w x z )
   (if (null *off*)
       (setq *off* 1.0)
   )
   (initget 6)
   (if (setq d (getdist (strcat "\nSpecify Offset <" (rtos *off*) ">: ")))
       (setq *off* d)
       (setq d *off*)
   )
   (while
       (progn (setvar 'errno 0) (setq e (car (entsel "\nSelect LWPolyline: ")))
           (cond
               (   (= 7 (getvar 'errno))
                   (princ "\nMissed, try again.")
               )
               (   (null e) nil)
               (   (/= "LWPOLYLINE" (cdr (assoc 0 (entget e))))
                   (princ "\nObject is not an LWPolyline.")
               )
               (   (setq p (getpoint "\nSpecify 1st Point: "))
                   (setq p (vlax-curve-getclosestpointto e (trans p 1 0)))
                   (while
                       (and
                           (setq  q (getpoint (trans p 0 1) "\nSpecify 2nd Point: "))
                           (equal p (setq q (vlax-curve-getclosestpointto e (trans q 1 0))) 1e-
                       )
                       (princ "\nPoints must be distinct.")
                   )
                   (if q
                       (progn
                           (if (> (setq m (vlax-curve-getparamatpoint e p))
                                  (setq n (vlax-curve-getparamatpoint e q))
                               )
                               (mapcar 'set '(m n p q) (list n m q p))
                           )
                           (setq e (entget e)
                                 h (reverse (member (assoc 39 e) (reverse e)))
                                 h (subst (cons 70 (logand (cdr (assoc 70 h)) (~ 1))) (assoc 70 h) h)
                                 l (LM:LWVertices e)
                                 z (assoc 210 e)
                           )
                           (repeat (fix m)
                               (setq l (cdr l))
                           )
                           (if (not (equal m (fix m) 1e-)
                               (setq x (car l)
                                     w (cdr (assoc 40 x))
                                     l
                                   (cons
                                       (list
                                           (cons  10 (trans p 0 (cdr z)))
                                           (cons  40 (+ w (* (- m (fix m)) (- (cdr (assoc 41 x)) w))))
                                           (assoc 41 x)
                                           (cons  42
                                               (tan
                                                   (*  (- (min n (1+ (fix m))) m)
                                                       (atan (cdr (assoc 42 x)))
                                                   )
                                               )
                                           )
                                       )
                                       (cdr l)
                                   )
                               )
                           )
                           (setq l (reverse l))
                           (repeat (+ (length l) (fix m) (- (fix n)) -1)
                               (setq l (cdr l))
                           )
                           (if (not (equal n (fix n) 1e-)
                               (setq x (car l)
                                     w (cdr (assoc 40 x))
                                     l
                                   (vl-list*
                                       (list
                                           (cons 10 (trans q 0 (cdr z)))
                                          '(40 . 0.0)
                                          '(41 . 0.0)
                                          '(42 . 0.0)
                                       )
                                       (list
                                           (assoc 10 x)
                                           (assoc 40 x)
                                           (cons  41
                                               (+ w
                                                   (*  (/ (- n (max m (fix n))) (- (1+ (fix n)) (max m (fix n))))
                                                       (- (cdr (assoc 41 x)) w)
                                                   )
                                               )
                                           )
                                           (cons  42
                                               (tan
                                                   (*  (if (< (fix n) m) 1.0 (- n (fix n)))
                                                       (atan (cdr (assoc 42 x)))
                                                   )
                                               )
                                           )
                                       )
                                       (cdr l)
                                   )
                               )
                           )
                           (setq p (getpoint "Specify point on side to offset or Enter for both: ")
                                   o (vlax-ename->vla-object(entmakex (append h (apply 'append (reverse l)) (list z))))
                                   ename (vlax-vla-object->ename o)
                           )
                           (if p
                             (progn
                               (princ "\nPoint selected!")
                               (command "_.offset" d ename p "")
                               (entdel ename)
                             )
                             (progn
                               (princ "\nPoint NOT selected!")
;                                (vlax-ename->vla-object o)
;                                (setq o (vlax-ename->vla-object(entmakex (append h (apply 'append (reverse l)) (list z)))))
                               (vl-catch-all-apply 'vla-offset (list o d))
                               (vl-catch-all-apply 'vla-offset (list o (- d)))
                               (vla-delete o)
                             )
                         )
                       )
                   )
               )
           )
       )
   )
   (princ)
)

;; Tangent  -  Lee Mac
;; Args: x - real

(defun tan ( x )
   (if (not (equal 0.0 (cos x) 1e-)
       (/ (sin x) (cos x))
   )
)

;; LW Vertices  -  Lee Mac
;; Returns a list of lists in which each sublist describes the position,
;; starting width, ending width and bulge of a vertex of an LWPolyline

(defun LM:LWVertices ( e )
   (if (setq e (member (assoc 10 e) e))
       (cons
           (list
               (assoc 10 e)
               (assoc 40 e)
               (assoc 41 e)
               (assoc 42 e)
           )
           (LM:LWVertices (cdr e))
       )
   )
)

;;----------------------------------------------------------------------;;

(vl-load-com)
(princ
   (strcat
       "\n:: OffsetSection.lsp | Version 1.1 | \\U+00A9 Lee Mac "
       (menucmd "m=$(edtime,0,yyyy)")
       " www.lee-mac.com ::"
       "\n:: Type \"offsec\" to Invoke ::"
   )
)
(princ)

;;----------------------------------------------------------------------;;
;;                             End of File                              ;;
;;----------------------------------------------------------------------;; 

Sorry Lee no offense, added option "Specify point on side to offset or Enter for both"

Edited by tombu
Added option "Specify point on side to offset or Enter for both"
Posted

Thanks Tombu. That is great. If I have a closed polyline and I select 2 points to offset between how does the routine know which portion of the closed polyline to offset? Sorry now I am being a bit finicky!!

Posted

Tombu would be possible after picking the two points to select a side of the two points to offset?

Posted
Tombu would be possible after picking the two points to select a side of the two points to offset?

Try downloading it again. I updated the code yesterday at 3:10 PM, just tested again, it prompts to either select a side of the polyline to offset or hit Enter to offset both sides same as Lee's original code. It works with closed polylines as well, but does it as if the polyline was not closed. It will not cross the origin (Current vertex 1 in Properties) to draw the offset.

Posted

Tombu. I downloaded your updated code and it works great only that I don't think I explained myself very well earlier. Why using the routine after selecting the polyline and choosing points to offset between the user selects a side to offset to but I think it should be to offset inside or outside and with the additional option to specify what side of then line between the selected points.

 

I am trying to make it as clear as possible but I don't know if I am succeeding very well.

 

I include a drawing that may help to explain. How do I choose between portion A or portion B of the polyline?

 

A B.jpg

Posted

Try this one:

;;------------------=={ Offset LWPolyline Section }==-------------------;;
;;                                                                      ;;
;;  This program prompts the user to specify an offset distance and to  ;;
;;  select an LWPolyline. The user is then prompted to specify two      ;;
;;  points on the LWPolyline enclosing the section to be offset. The    ;;
;;  progam will proceed to offset all segments between the two given    ;;
;;  points to both sides by the specified distance.                     ;;
;;                                                                      ;;
;;  The program is compatible with LWPolylines of constant or varying   ;;
;;  width, with straight and/or arc segments, and defined in any UCS    ;;
;;  construction plane.                                                 ;;
;;----------------------------------------------------------------------;;
;;  Author:  Lee Mac, Copyright © 2013  -  www.lee-mac.com              ;;
;;----------------------------------------------------------------------;;
;;  Version 1.0    -    27-12-2012                                      ;;
;;                                                                      ;;
;;  First release.                                                      ;;
;;----------------------------------------------------------------------;;
;;  Version 1.1    -    05-04-2013                                      ;;
;;                                                                      ;;
;;  Fixed bug when offsetting polyline arc segments.                    ;;
;;----------------------------------------------------------------------;;
;;  Version WM78    -    06-10-2015                                      ;;
;;  http://www.cadtutor.net/forum/showthread.php?92673-Offset-only-a-section-of-a-closed-polyline&p=634498#post634498#14
;;  Set offset options Inside, Outside, or Both.                    ;;
;;----------------------------------------------------------------------;;

(defun c:offsec ( / d e h l m n o p q w x z str1)
   (if (null *off*)
       (setq *off* 1.0)
   )
   (initget 6)
   (if (setq d (getdist (strcat "\nSpecify Offset <" (rtos *off*) ">: ")))
       (setq *off* d)
       (setq d *off*)
   )
   (while
       (progn (setvar 'errno 0) (setq e (car (entsel "\nSelect LWPolyline: ")))
           (cond
               (   (= 7 (getvar 'errno))
                   (princ "\nMissed, try again.")
               )
               (   (null e) nil)
               (   (/= "LWPOLYLINE" (cdr (assoc 0 (entget e))))
                   (princ "\nObject is not an LWPolyline.")
               )
               (   (setq p (getpoint "\nSpecify 1st Point: "))
                   (setq p (vlax-curve-getclosestpointto e (trans p 1 0)))
                   (while
                       (and
                           (setq  q (getpoint (trans p 0 1) "\nSpecify 2nd Point: "))
                           (equal p (setq q (vlax-curve-getclosestpointto e (trans q 1 0))) 1e-
                       )
                       (princ "\nPoints must be distinct.")
                   )
                   (initget "Inside Outside Both")
                   (or
                     (setq str1 (getkword " [inside/Outside/Both] <Both>: "))
                     (setq str1 "Both")
                   )
                   (if q
                       (progn
                           (if (> (setq m (vlax-curve-getparamatpoint e p))
                                  (setq n (vlax-curve-getparamatpoint e q))
                               )
                               (mapcar 'set '(m n p q) (list n m q p))
                           )
                           (setq e (entget e)
                                 h (reverse (member (assoc 39 e) (reverse e)))
                                 h (subst (cons 70 (logand (cdr (assoc 70 h)) (~ 1))) (assoc 70 h) h)
                                 l (LM:LWVertices e)
                                 z (assoc 210 e)
                           )
                           (repeat (fix m)
                               (setq l (cdr l))
                           )
                           (if (not (equal m (fix m) 1e-)
                               (setq x (car l)
                                     w (cdr (assoc 40 x))
                                     l
                                   (cons
                                       (list
                                           (cons  10 (trans p 0 (cdr z)))
                                           (cons  40 (+ w (* (- m (fix m)) (- (cdr (assoc 41 x)) w))))
                                           (assoc 41 x)
                                           (cons  42
                                               (tan
                                                   (*  (- (min n (1+ (fix m))) m)
                                                       (atan (cdr (assoc 42 x)))
                                                   )
                                               )
                                           )
                                       )
                                       (cdr l)
                                   )
                               )
                           )
                           (setq l (reverse l))
                           (repeat (+ (length l) (fix m) (- (fix n)) -1)
                               (setq l (cdr l))
                           )
                           (if (not (equal n (fix n) 1e-)
                               (setq x (car l)
                                     w (cdr (assoc 40 x))
                                     l
                                   (vl-list*
                                       (list
                                           (cons 10 (trans q 0 (cdr z)))
                                          '(40 . 0.0)
                                          '(41 . 0.0)
                                          '(42 . 0.0)
                                       )
                                       (list
                                           (assoc 10 x)
                                           (assoc 40 x)
                                           (cons  41
                                               (+ w
                                                   (*  (/ (- n (max m (fix n))) (- (1+ (fix n)) (max m (fix n))))
                                                       (- (cdr (assoc 41 x)) w)
                                                   )
                                               )
                                           )
                                           (cons  42
                                               (tan
                                                   (*  (if (< (fix n) m) 1.0 (- n (fix n)))
                                                       (atan (cdr (assoc 42 x)))
                                                   )
                                               )
                                           )
                                       )
                                       (cdr l)
                                   )
                               )
                           )
                           (setq o
                               (vlax-ename->vla-object
                                   (entmakex (append h (apply 'append (reverse l)) (list z)))
                               )
                           )
                           (cond
                             ((= str1 "Inside")
                               (vl-catch-all-apply 'vla-offset (list o (- d)))
                             )
                             ((= str1 "Outside")
                               (vl-catch-all-apply 'vla-offset (list o d))
                             )
                             ((= str1 "Both")
                               (vl-catch-all-apply 'vla-offset (list o d))
                               (vl-catch-all-apply 'vla-offset (list o (- d)))
                             )
                           )
                           (vla-delete o)
                       )
                   )
               )
           )
       )
   )
   (princ)
)

;; Tangent  -  Lee Mac
;; Args: x - real

(defun tan ( x )
   (if (not (equal 0.0 (cos x) 1e-)
       (/ (sin x) (cos x))
   )
)

;; LW Vertices  -  Lee Mac
;; Returns a list of lists in which each sublist describes the position,
;; starting width, ending width and bulge of a vertex of an LWPolyline

(defun LM:LWVertices ( e )
   (if (setq e (member (assoc 10 e) e))
       (cons
           (list
               (assoc 10 e)
               (assoc 40 e)
               (assoc 41 e)
               (assoc 42 e)
           )
           (LM:LWVertices (cdr e))
       )
   )
)

;;----------------------------------------------------------------------;;

(vl-load-com)
(princ
   (strcat
       "\n:: OffsetSection.lsp | Version 1.1 | \\U+00A9 Lee Mac "
       (menucmd "m=$(edtime,0,yyyy)")
       " www.lee-mac.com ::"
       "\n:: Type \"offsec\" to Invoke ::"
   )
)
(princ)

;;----------------------------------------------------------------------;;
;;                             End of File                              ;;
;;----------------------------------------------------------------------;;

Posted

Thanks Tombu but I hoping to be able to select whether I want to offset portion A or portion B of the line inside or outside based on the above diagram.

Posted
Thanks Tombu but I hoping to be able to select whether I want to offset portion A or portion B of the line inside or outside based on the above diagram.

 

The polyline has a start and end and the lisp will work on anything along it. Even though it's closed there's no way lisp can cross the origin (Current vertex 1 in Properties) to draw the other offset portion that I know of.

 

Sorry,

Posted

Ok. Thanks for all your help Tombu.

  • 3 months later...
Posted

Tombu,

Your modification is great, and will really help me, if it can be updated a bit..... I am just not adept at coding,(and especially Lee's code ;-))

I need to offset site plans to create setback lines at different distances....... (had started a new thread some time back for this... but this thread is pretty close to it)

Can we choose the two points as per your modification

This could be called front setback.

Always choose Inside offset

Offset them at fixed known distances

have each offset of a different colour 1,2,3,4,5.....

Continue with Side 1 setback (with different fixed offset distances)

and Side 2 setback (with different fixed offset distances)

and Rear setback (with different fixed offset distances)

 

The resultant coloured setback lines could be matched and manually filletted to get continuous setback lines

 

am attaching a drawing trying to explain.....

 

thanks for your help.....

site setback.dwg

Posted

Attaching the offset distances and the line colours (just in case it is possible)

 

***** fingers crossed******o:)

 

Basically we will need to identify each segment ..... if its front, the front setback offsets will need to be done,

if the segment is identified as S1, the side one segments need to be offset ted...

and so on.... Side 2 & rear....

 

tough one....... ?????

offset + line color.jpg

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