Jump to content

Recommended Posts

Posted

Hi Guys attached drawing is of a beam layout.

Iam suppose to Make Center Lines for all beams.

And there are still 12 Floors of the same size :shock:

Hate doing boring stuff like this which are time consuming but equally importantpart of my job so.

Any way for speeding up process would be highly helpful.

Thank you.

new block.dwg

Posted (edited)

Draw 3 lines in first go put c/l on a different layer

 

Heres a lisp that takes a line and makes two new lines just remove the erase bit and c/l will stay just edit the defuns for edge beam sizes

 

; pipe offset for different size pipes
; by Alan H July 2014

(vl-load-com)
(defun trap (errmsg)
 (prompt "\nAn error has occured.")
 (setvar "osmode" oldsnap)
 (setq *error* temperr)
)
(setq temperr *error*)
(setq *error* trap)
(setq  doc (vla-get-activedocument (vlax-get-acad-object))) ; open database
(defun loadLinetype (doc LineTypeName FileName)
 (if (and
       (not (existLinetype doc LineTypeName))
       (vl-catch-all-error-p
         (vl-catch-all-apply
           'vla-load
           (list
             (vla-get-Linetypes doc)
             LineTypeName
             FileName
           )
         )
       )
     )
   nil
   T
 )
)
(defun existLinetype (doc LineTypeName / item loaded)
 (vlax-for item (vla-get-linetypes doc)
   (if (= (strcase (vla-get-name item)) (strcase LineTypeName))
     (setq loaded T)
   )
 )
)
;load missing linetypes
;;; returns: T if loaded else nil
;(loadLinetype doc "EX_PIPE250" "custom.lin")
(defun pipeoffset (w / ang stpt pt3 pt4 obj whatis)
(setq oldsnap (getvar "osmode"))
(setvar "osmode" 0)
(setq temperr *error*)
(setq *error* trap)
(setq obj (entsel "\nPick line"))
(setq objtype (vla-get-objectname (vlax-ename->vla-object (car obj))))
(if (= "AcDbLINE" objtype)
 (progn
    (alert "You have picked an object which is not a line\nTry Again")
    (exit)
 )
 (princ "\nLine")
)
(setq stpt (assoc 10 (entget (car obj))))
(setq stpt (list (nth 1 stpt)(nth 2 stpt)))
(setq endpt (assoc 11 (entget (car obj))))
(setq endpt (list (nth 1 endpt)(nth 2 endpt)))
(setq ang (angle stpt endpt))
(setq pt3 (polar stpt (+ ang (/ pi 2.0)) 1.0))
(setq pt4 (polar stpt (- ang (/ pi 2.0)) 1.0))
(command "offset" w obj pt3 "")
;(Command "chprop" "last" "" "LT" "EX_PIPE250" "")
(command "offset" w obj pt4 "")
;(Command "chprop" "last" "" "LT" "EX_PIPE250" "")
;(command "Erase" obj "")
(setvar "osmode" oldsnap)
)

(defun c:P100 ()
(pipeoffset 0.06)
)
(defun c:P150 ()
(pipeoffset 0.08)
)
(defun c:P225 ()
(pipeoffset 0.152)
)
(defun c:P300 ()
(pipeoffset 0.19)
)
(defun c:P375 ()
(pipeoffset 0.228)
)
(defun c:P450 ()
(pipeoffset 0.265)
)
(defun c:P525 ()
(pipeoffset 0.302)
)
(defun c:P600 ()
(pipeoffset 0.34)
)
(defun c:P675 ()
(pipeoffset 0.34)
)
(defun c:P750 ()
(pipeoffset 0.415)
)
(defun c:P825 ()
(pipeoffset 0.455)
)
(defun c:P900 ()
(pipeoffset 0.49)
)
(defun c:P975 ()
(pipeoffset 0.528)
)
(defun c:P1050 ()
(pipeoffset 0.565)
)
(defun c:P1125 ()
(pipeoffset 0.6)
)
(defun c:P1200 ()
(pipeoffset 0.64)
)

(setq *error* temperr)
(princ)

Edited by BIGAL
remove linetype coding
Posted

Sorry for the late reply guys, stuckup with work at construction site got to desk now.

 

@BIGAL thanks mate but i was not able to get it to work. removed this part

(command "Erase" obj "")

then edited this line to beam size corresponding in my drawing. mainly 230mm, 300mm and 1000mm

Example : edited this line in the code to

(defun c:P450 () to (defun c:P230 ()

(pipeoffset 0.265) kept this line the same, think has to change.

 

saved the text as .LSP loaded it and typed in p230 it asked to pick a line i was like iam getting some where with this for a fraction of second and then when i select a lin :oops: An error has occured.

and with my LISP skill of apploading and typing the command i think iam back to ask help again :cry:

 

 

@ SLW210 : Thanks i found some lisp around on the internet which are very similar to the lisp posted on that thread. cpoly by Lee mac is a great one perfect for any shape of polylines. just picking the line first line and then the second line in my case is still time consuming i increased the pickbox size for easiness, but still iam spending aroung half hour to 45mins . being able to select two lines with a marquee selection would really help cutting the time down i guess. i reached this page

http://www.afralisp.net/autolisp/tutorials/selection-sets.php

hoping to learn and edit the selection to marquee style and realized it takes more than that alone :ouch:

pic.jpg

lee cenlin cpoly.lsp

Posted

The problem will be the linetype in the code I draw using a particular one. I have changed the code it should now draw in current linetype look at the lines with semicolon ; at start. The ; means remarks and what comes after it does not run.

Posted

Sir BIGAL i dont understand what you said :(

Posted (edited)

Was continuing making the centerlines with Lee Mac's Lisp for center lines but hit a glitch. it works fine with straight lines, curved lines, inclined lines, but when i used it on angled continuous polylines i get the corner filleted. attached image and the LISP code Below. Please help.

 

(defun c:cPoly (/ ent1 ent2 i len pt p1 ptlst)
 (vl-load-com)

 (if (and (setq ent1 (car (entsel "\nSelect First Polyline: ")))
          (wcmatch (cdr (assoc 0 (entget ent1))) "*POLYLINE")
          (setq ent2 (car (entsel "\nSelect Second Polyline: ")))
          (wcmatch (cdr (assoc 0 (entget ent2))) "*POLYLINE"))
   (progn
     (setq i -1 len (/ (vla-get-Length
                         (vlax-ename->vla-object ent1)) 100.))
     
     (while (setq pt (vlax-curve-getPointatDist ent1 (* (setq i (1+ i)) len)))
       (setq p1    (vlax-curve-getClosestPointto ent2 pt t)
             ptlst (cons (polar pt (angle pt p1) (/ (distance pt p1) 2.)) ptlst)))
     
     (setq ptlst (apply (function append)
                        (mapcar
                          (function
                            (lambda (x) (list (car x) (cadr x)))) ptlst)))
     
     (vla-AddLightWeightPolyline
       (vla-get-ModelSpace
         (vla-get-ActiveDocument (vlax-get-acad-object)))
       (variant
         (vlax-safearray-fill
           (safearray vlax-VBDouble (cons 0 (1- (length ptlst)))) ptlst)))))

 (princ))

CPOLY.jpg

Edited by suryacad
Posted

Thanks for guiding me to the Thread marko_ribar , Helped a lot :thumbsup:

Posted (edited)
Thanks for guiding me to the Thread marko_ribar , Helped a lot :thumbsup:

 

You're welcome... If you don't have A2011+, maybe try this code... Picked LWPOLYLINES must be correct offset pair (the same number of vertices)... It should work and in some other UCS, just you'll have to set up UCS to be parallel with reference LWPOLYLINES...

 

[b][color=#FF0000]([/color][/b][color=BLUE]defun[/color] [color=BLUE]c:cenoffpls[/color] [b][color=#80FF00]([/color][/b] [color=BLUE]/[/color] chkoff _sel es ed pes ped off n k [b][color=#80FF00])[/color][/b]

 [b][color=#80FF00]([/color][/b][color=BLUE]defun[/color] chkoff [b][color=#00FFFF]([/color][/b] es ed fuzz [color=BLUE]/[/color] member-fuzz esd edd pes ped eld edd10-42 k kk mm edd10-42g eddr10-42g eld10-42 eld10-42g [b][color=#00FFFF])[/color][/b] [b][color=#00FFFF]([/color][/b][color=BLUE]vl-load-com[/color][b][color=#00FFFF])[/color][/b]
 
   [b][color=#00FFFF]([/color][/b][color=BLUE]defun[/color] member-fuzz [b][color=#0080FF]([/color][/b] e l f [b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]vl-member-if[/color] '[b][color=#FF00FF]([/color][/b][color=BLUE]lambda[/color] [b][color=#FF0000]([/color][/b] x [b][color=#FF0000])[/color][/b] [b][color=#FF0000]([/color][/b][color=BLUE]and[/color] [b][color=#80FF00]([/color][/b][color=BLUE]equal[/color] [b][color=#00FFFF]([/color][/b][color=BLUE]car[/color] e[b][color=#00FFFF])[/color][/b] [b][color=#00FFFF]([/color][/b][color=BLUE]car[/color] x[b][color=#00FFFF])[/color][/b] f[b][color=#80FF00])[/color][/b] [b][color=#80FF00]([/color][/b][color=BLUE]equal[/color] [b][color=#00FFFF]([/color][/b][color=BLUE]cadr[/color] e[b][color=#00FFFF])[/color][/b] [b][color=#00FFFF]([/color][/b][color=BLUE]cadr[/color] x[b][color=#00FFFF])[/color][/b] f[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b][b][color=#FF00FF])[/color][/b] l[b][color=#0080FF])[/color][/b]
   [b][color=#00FFFF])[/color][/b]
 
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] esd [b][color=#0080FF]([/color][/b][color=BLUE]entget[/color] es[b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] edd [b][color=#0080FF]([/color][/b][color=BLUE]entget[/color] ed[b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] pes [b][color=#0080FF]([/color][/b][color=BLUE]vlax-curve-getpointatparam[/color] es 0.5[b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] ped [b][color=#0080FF]([/color][/b][color=BLUE]vlax-curve-getclosestpointto[/color] ed pes[b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]command[/color] [color=BROWN]"_.OFFSET"[/color] [color=BROWN]"_T"[/color] es [b][color=#0080FF]([/color][/b][color=BLUE]trans[/color] ped 0 1[b][color=#0080FF])[/color][/b] [color=BROWN]""[/color][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] eld [b][color=#0080FF]([/color][/b][color=BLUE]entget[/color] [b][color=#FF00FF]([/color][/b][color=BLUE]entlast[/color][b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]entdel[/color] [b][color=#0080FF]([/color][/b][color=BLUE]entlast[/color][b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] edd10-42 [b][color=#0080FF]([/color][/b][color=BLUE]vl-remove-if-not[/color] '[b][color=#FF00FF]([/color][/b][color=BLUE]lambda[/color] [b][color=#FF0000]([/color][/b] x [b][color=#FF0000])[/color][/b] [b][color=#FF0000]([/color][/b][color=BLUE]or[/color] [b][color=#80FF00]([/color][/b][color=BLUE]eq[/color] [b][color=#00FFFF]([/color][/b][color=BLUE]car[/color] x[b][color=#00FFFF])[/color][/b] 10[b][color=#80FF00])[/color][/b] [b][color=#80FF00]([/color][/b][color=BLUE]eq[/color] [b][color=#00FFFF]([/color][/b][color=BLUE]car[/color] x[b][color=#00FFFF])[/color][/b] 42[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b][b][color=#FF00FF])[/color][/b] edd[b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] k -1[b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]repeat[/color] [b][color=#0080FF]([/color][/b][color=BLUE]/[/color] [b][color=#FF00FF]([/color][/b][color=BLUE]length[/color] edd10-42[b][color=#FF00FF])[/color][/b] 2[b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]setq[/color] kk [b][color=#FF00FF]([/color][/b][color=BLUE]*[/color] [b][color=#FF0000]([/color][/b][color=BLUE]setq[/color] k [b][color=#80FF00]([/color][/b][color=BLUE]1+[/color] k[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b] 2[b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]setq[/color] mm [b][color=#FF00FF]([/color][/b][color=BLUE]1+[/color] kk[b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]setq[/color] edd10-42g [b][color=#FF00FF]([/color][/b][color=BLUE]cons[/color] [b][color=#FF0000]([/color][/b][color=BLUE]list[/color] [b][color=#80FF00]([/color][/b][color=BLUE]nth[/color] kk edd10-42[b][color=#80FF00])[/color][/b] [b][color=#80FF00]([/color][/b][color=BLUE]nth[/color] mm edd10-42[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b] edd10-42g[b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b]
   [b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] edd10-42g [b][color=#0080FF]([/color][/b][color=BLUE]reverse[/color] edd10-42g[b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]if[/color] [b][color=#0080FF]([/color][/b][color=BLUE]eq[/color] 0 [b][color=#FF00FF]([/color][/b][color=BLUE]logand[/color] [b][color=#FF0000]([/color][/b][color=BLUE]cdr[/color] [b][color=#80FF00]([/color][/b][color=BLUE]assoc[/color] 70 edd[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b] 1[b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b] [b][color=#0080FF]([/color][/b][color=BLUE]entupd[/color] [b][color=#FF00FF]([/color][/b][color=BLUE]cdr[/color] [b][color=#FF0000]([/color][/b][color=BLUE]assoc[/color] -1 [b][color=#80FF00]([/color][/b][color=BLUE]entmod[/color] [b][color=#00FFFF]([/color][/b][color=BLUE]append[/color] [b][color=#0080FF]([/color][/b][color=BLUE]if[/color] [b][color=#FF00FF]([/color][/b][color=BLUE]assoc[/color] 91 edd[b][color=#FF00FF])[/color][/b] [b][color=#FF00FF]([/color][/b][color=BLUE]reverse[/color] [b][color=#FF0000]([/color][/b][color=BLUE]cdddr[/color] [b][color=#80FF00]([/color][/b][color=BLUE]reverse[/color] edd[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b][b][color=#FF00FF])[/color][/b] [b][color=#FF00FF]([/color][/b][color=BLUE]reverse[/color] [b][color=#FF0000]([/color][/b][color=BLUE]cddr[/color] [b][color=#80FF00]([/color][/b][color=BLUE]reverse[/color] edd[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b][b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b] [b][color=#0080FF]([/color][/b][color=BLUE]if[/color] [b][color=#FF00FF]([/color][/b][color=BLUE]assoc[/color] 91 edd[b][color=#FF00FF])[/color][/b] [b][color=#FF00FF]([/color][/b][color=BLUE]list[/color] [b][color=#FF0000]([/color][/b][color=BLUE]cadadr[/color] [b][color=#80FF00]([/color][/b][color=BLUE]reverse[/color] edd10-42g[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b] [b][color=#FF0000]([/color][/b][color=BLUE]cadr[/color] [b][color=#80FF00]([/color][/b][color=BLUE]reverse[/color] edd[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b] [b][color=#FF0000]([/color][/b][color=BLUE]last[/color] edd[b][color=#FF0000])[/color][/b][b][color=#FF00FF])[/color][/b] [b][color=#FF00FF]([/color][/b][color=BLUE]list[/color] [b][color=#FF0000]([/color][/b][color=BLUE]cadadr[/color] [b][color=#80FF00]([/color][/b][color=BLUE]reverse[/color] edd10-42g[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b] [b][color=#FF0000]([/color][/b][color=BLUE]last[/color] edd[b][color=#FF0000])[/color][/b][b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b][b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b][b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] edd [b][color=#0080FF]([/color][/b][color=BLUE]entget[/color] ed[b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] edd10-42g [color=BLUE]nil[/color][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] edd10-42 [b][color=#0080FF]([/color][/b][color=BLUE]vl-remove-if-not[/color] '[b][color=#FF00FF]([/color][/b][color=BLUE]lambda[/color] [b][color=#FF0000]([/color][/b] x [b][color=#FF0000])[/color][/b] [b][color=#FF0000]([/color][/b][color=BLUE]or[/color] [b][color=#80FF00]([/color][/b][color=BLUE]eq[/color] [b][color=#00FFFF]([/color][/b][color=BLUE]car[/color] x[b][color=#00FFFF])[/color][/b] 10[b][color=#80FF00])[/color][/b] [b][color=#80FF00]([/color][/b][color=BLUE]eq[/color] [b][color=#00FFFF]([/color][/b][color=BLUE]car[/color] x[b][color=#00FFFF])[/color][/b] 42[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b][b][color=#FF00FF])[/color][/b] edd[b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] k -1[b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]repeat[/color] [b][color=#0080FF]([/color][/b][color=BLUE]/[/color] [b][color=#FF00FF]([/color][/b][color=BLUE]length[/color] edd10-42[b][color=#FF00FF])[/color][/b] 2[b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]setq[/color] kk [b][color=#FF00FF]([/color][/b][color=BLUE]*[/color] [b][color=#FF0000]([/color][/b][color=BLUE]setq[/color] k [b][color=#80FF00]([/color][/b][color=BLUE]1+[/color] k[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b] 2[b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]setq[/color] mm [b][color=#FF00FF]([/color][/b][color=BLUE]1+[/color] kk[b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]setq[/color] edd10-42g [b][color=#FF00FF]([/color][/b][color=BLUE]cons[/color] [b][color=#FF0000]([/color][/b][color=BLUE]list[/color] [b][color=#80FF00]([/color][/b][color=BLUE]nth[/color] kk edd10-42[b][color=#80FF00])[/color][/b] [b][color=#80FF00]([/color][/b][color=BLUE]nth[/color] mm edd10-42[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b] edd10-42g[b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b]
   [b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] edd10-42g [b][color=#0080FF]([/color][/b][color=BLUE]reverse[/color] edd10-42g[b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] eddr10-42g [b][color=#0080FF]([/color][/b][color=BLUE]mapcar[/color] '[b][color=#FF00FF]([/color][/b][color=BLUE]lambda[/color] [b][color=#FF0000]([/color][/b] x y [b][color=#FF0000])[/color][/b] [b][color=#FF0000]([/color][/b][color=BLUE]list[/color] [b][color=#80FF00]([/color][/b][color=BLUE]car[/color] x[b][color=#80FF00])[/color][/b] [b][color=#80FF00]([/color][/b][color=BLUE]cons[/color] 42 [b][color=#00FFFF]([/color][/b][color=BLUE]-[/color] [b][color=#0080FF]([/color][/b][color=BLUE]cdadr[/color] y[b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b][b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b][b][color=#FF00FF])[/color][/b] [b][color=#FF00FF]([/color][/b][color=BLUE]reverse[/color] edd10-42g[b][color=#FF00FF])[/color][/b] [b][color=#FF00FF]([/color][/b][color=BLUE]reverse[/color] [b][color=#FF0000]([/color][/b][color=BLUE]cons[/color] [b][color=#80FF00]([/color][/b][color=BLUE]if[/color] [b][color=#00FFFF]([/color][/b][color=BLUE]eq[/color] 1 [b][color=#0080FF]([/color][/b][color=BLUE]logand[/color] [b][color=#FF00FF]([/color][/b][color=BLUE]cdr[/color] [b][color=#FF0000]([/color][/b][color=BLUE]assoc[/color] 70 edd[b][color=#FF0000])[/color][/b][b][color=#FF00FF])[/color][/b] 1[b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b] [b][color=#00FFFF]([/color][/b][color=BLUE]last[/color] edd10-42g[b][color=#00FFFF])[/color][/b] [b][color=#00FFFF]([/color][/b][color=BLUE]car[/color] edd10-42g[b][color=#00FFFF])[/color][/b][b][color=#80FF00])[/color][/b] [b][color=#80FF00]([/color][/b][color=BLUE]reverse[/color] [b][color=#00FFFF]([/color][/b][color=BLUE]cdr[/color] [b][color=#0080FF]([/color][/b][color=BLUE]reverse[/color] edd10-42g[b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b][b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b][b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] eld10-42 [b][color=#0080FF]([/color][/b][color=BLUE]vl-remove-if-not[/color] '[b][color=#FF00FF]([/color][/b][color=BLUE]lambda[/color] [b][color=#FF0000]([/color][/b] x [b][color=#FF0000])[/color][/b] [b][color=#FF0000]([/color][/b][color=BLUE]or[/color] [b][color=#80FF00]([/color][/b][color=BLUE]eq[/color] [b][color=#00FFFF]([/color][/b][color=BLUE]car[/color] x[b][color=#00FFFF])[/color][/b] 10[b][color=#80FF00])[/color][/b] [b][color=#80FF00]([/color][/b][color=BLUE]eq[/color] [b][color=#00FFFF]([/color][/b][color=BLUE]car[/color] x[b][color=#00FFFF])[/color][/b] 42[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b][b][color=#FF00FF])[/color][/b] eld[b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] k -1[b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]repeat[/color] [b][color=#0080FF]([/color][/b][color=BLUE]/[/color] [b][color=#FF00FF]([/color][/b][color=BLUE]length[/color] eld10-42[b][color=#FF00FF])[/color][/b] 2[b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]setq[/color] kk [b][color=#FF00FF]([/color][/b][color=BLUE]*[/color] [b][color=#FF0000]([/color][/b][color=BLUE]setq[/color] k [b][color=#80FF00]([/color][/b][color=BLUE]1+[/color] k[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b] 2[b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]setq[/color] mm [b][color=#FF00FF]([/color][/b][color=BLUE]1+[/color] kk[b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]setq[/color] eld10-42g [b][color=#FF00FF]([/color][/b][color=BLUE]cons[/color] [b][color=#FF0000]([/color][/b][color=BLUE]list[/color] [b][color=#80FF00]([/color][/b][color=BLUE]nth[/color] kk eld10-42[b][color=#80FF00])[/color][/b] [b][color=#80FF00]([/color][/b][color=BLUE]nth[/color] mm eld10-42[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b] eld10-42g[b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b]
   [b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] eld10-42g [b][color=#0080FF]([/color][/b][color=BLUE]reverse[/color] eld10-42g[b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]if[/color] [b][color=#0080FF]([/color][/b][color=BLUE]or[/color]
         [b][color=#FF00FF]([/color][/b][color=BLUE]vl-every[/color] '[b][color=#FF0000]([/color][/b][color=BLUE]lambda[/color] [b][color=#80FF00]([/color][/b] x [b][color=#80FF00])[/color][/b] [b][color=#80FF00]([/color][/b]member-fuzz x edd10-42g fuzz[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b] eld10-42g[b][color=#FF00FF])[/color][/b]
         [b][color=#FF00FF]([/color][/b][color=BLUE]vl-every[/color] '[b][color=#FF0000]([/color][/b][color=BLUE]lambda[/color] [b][color=#80FF00]([/color][/b] x [b][color=#80FF00])[/color][/b] [b][color=#80FF00]([/color][/b]member-fuzz x eddr10-42g fuzz[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b] eld10-42g[b][color=#FF00FF])[/color][/b]
       [b][color=#0080FF])[/color][/b]
       [color=BLUE]t[/color]
       [color=BLUE]nil[/color]
   [b][color=#00FFFF])[/color][/b]
 [b][color=#80FF00])[/color][/b]
 
 [b][color=#80FF00]([/color][/b][color=BLUE]defun[/color] _sel [b][color=#00FFFF]([/color][/b] msg etype [color=BLUE]/[/color] e [b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]setq[/color] e [b][color=#0080FF]([/color][/b][color=BLUE]car[/color] [b][color=#FF00FF]([/color][/b][color=BLUE]entsel[/color] msg[b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]cond[/color]
     [b][color=#0080FF]([/color][/b] [b][color=#FF00FF]([/color][/b][color=BLUE]null[/color] e[b][color=#FF00FF])[/color][/b]
       [b][color=#FF00FF]([/color][/b][color=BLUE]prompt[/color] [color=BROWN]"\nMissed... Try again..."[/color][b][color=#FF00FF])[/color][/b]
       [b][color=#FF00FF]([/color][/b]_sel msg etype[b][color=#FF00FF])[/color][/b]
     [b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b] [b][color=#FF00FF]([/color][/b][color=BLUE]/=[/color] [b][color=#FF0000]([/color][/b][color=BLUE]cdr[/color] [b][color=#80FF00]([/color][/b][color=BLUE]assoc[/color] 0 [b][color=#00FFFF]([/color][/b][color=BLUE]entget[/color] e[b][color=#00FFFF])[/color][/b][b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b] etype[b][color=#FF00FF])[/color][/b]
       [b][color=#FF00FF]([/color][/b][color=BLUE]prompt[/color] [color=BROWN]"\nPicked wrong entity type... Try again..."[/color][b][color=#FF00FF])[/color][/b]
       [b][color=#FF00FF]([/color][/b]_sel msg etype[b][color=#FF00FF])[/color][/b]
     [b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b] [b][color=#FF00FF]([/color][/b][color=BLUE]=[/color] 4 [b][color=#FF0000]([/color][/b][color=BLUE]logand[/color] [b][color=#80FF00]([/color][/b][color=BLUE]cdr[/color] [b][color=#00FFFF]([/color][/b][color=BLUE]assoc[/color] 70 [b][color=#0080FF]([/color][/b][color=BLUE]tblsearch[/color] [color=BROWN]"LAYER"[/color] [b][color=#FF00FF]([/color][/b][color=BLUE]cdr[/color] [b][color=#FF0000]([/color][/b][color=BLUE]assoc[/color] 8 [b][color=#80FF00]([/color][/b][color=BLUE]entget[/color] e[b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b][b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b][b][color=#00FFFF])[/color][/b][b][color=#80FF00])[/color][/b] 4[b][color=#FF0000])[/color][/b][b][color=#FF00FF])[/color][/b]
       [b][color=#FF00FF]([/color][/b][color=BLUE]prompt[/color] [color=BROWN]"\nPicked entity is on locked layer... Try again..."[/color][b][color=#FF00FF])[/color][/b]
       [b][color=#FF00FF]([/color][/b]_sel msg etype[b][color=#FF00FF])[/color][/b]
     [b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b] [b][color=#FF00FF]([/color][/b][color=BLUE]eq[/color] [b][color=#FF0000]([/color][/b][color=BLUE]cdr[/color] [b][color=#80FF00]([/color][/b][color=BLUE]assoc[/color] 0 [b][color=#00FFFF]([/color][/b][color=BLUE]entget[/color] e[b][color=#00FFFF])[/color][/b][b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b] etype[b][color=#FF00FF])[/color][/b]
       e
     [b][color=#0080FF])[/color][/b]
   [b][color=#00FFFF])[/color][/b]
 [b][color=#80FF00])[/color][/b]
 
 [b][color=#80FF00]([/color][/b][color=BLUE]vl-load-com[/color][b][color=#80FF00])[/color][/b]
 
 [b][color=#80FF00]([/color][/b][color=BLUE]setq[/color] es [b][color=#00FFFF]([/color][/b]_sel [color=BROWN]"\nPick first LWPOLYLINE..."[/color] [color=BROWN]"LWPOLYLINE"[/color][b][color=#00FFFF])[/color][/b][b][color=#80FF00])[/color][/b]
 [b][color=#80FF00]([/color][/b][color=BLUE]setq[/color] ed [b][color=#00FFFF]([/color][/b]_sel [color=BROWN]"\nPick second LWPOLYLINE..."[/color] [color=BROWN]"LWPOLYLINE"[/color][b][color=#00FFFF])[/color][/b][b][color=#80FF00])[/color][/b]
 [b][color=#80FF00]([/color][/b][color=BLUE]if[/color] [b][color=#00FFFF]([/color][/b]chkoff es ed 1e-4[b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]progn[/color]
     [b][color=#0080FF]([/color][/b][color=BLUE]setq[/color] pes [b][color=#FF00FF]([/color][/b][color=BLUE]vlax-curve-getpointatparam[/color] es 0.5[b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]setq[/color] ped [b][color=#FF00FF]([/color][/b][color=BLUE]vlax-curve-getclosestpointto[/color] ed pes[b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]setq[/color] off [b][color=#FF00FF]([/color][/b][color=BLUE]distance[/color] ped [b][color=#FF0000]([/color][/b][color=BLUE]vlax-curve-getclosestpointto[/color] es ped[b][color=#FF0000])[/color][/b][b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]initget[/color] 6[b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]setq[/color] n [b][color=#FF00FF]([/color][/b][color=BLUE]getint[/color] [color=BROWN]"\nSpecify number of offsets <1> : "[/color][b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]if[/color] [b][color=#FF00FF]([/color][/b][color=BLUE]null[/color] n[b][color=#FF00FF])[/color][/b] [b][color=#FF00FF]([/color][/b][color=BLUE]setq[/color] n 1[b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]setq[/color] off [b][color=#FF00FF]([/color][/b][color=BLUE]/[/color] off [b][color=#FF0000]([/color][/b][color=BLUE]1+[/color] n[b][color=#FF0000])[/color][/b][b][color=#FF00FF])[/color][/b][b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]setq[/color] k 0[b][color=#0080FF])[/color][/b]
     [b][color=#0080FF]([/color][/b][color=BLUE]repeat[/color] n
       [b][color=#FF00FF]([/color][/b][color=BLUE]command[/color] [color=BROWN]"_.OFFSET"[/color] [b][color=#FF0000]([/color][/b][color=BLUE]*[/color] off [b][color=#80FF00]([/color][/b][color=BLUE]setq[/color] k [b][color=#00FFFF]([/color][/b][color=BLUE]1+[/color] k[b][color=#00FFFF])[/color][/b][b][color=#80FF00])[/color][/b][b][color=#FF0000])[/color][/b] es [b][color=#FF0000]([/color][/b][color=BLUE]trans[/color] ped 0 1[b][color=#FF0000])[/color][/b] [color=BROWN]""[/color][b][color=#FF00FF])[/color][/b]
     [b][color=#0080FF])[/color][/b]
   [b][color=#00FFFF])[/color][/b]
   [b][color=#00FFFF]([/color][/b][color=BLUE]alert[/color] [color=BROWN]"Picked LWPOLYLINES don't belong to offset pair..."[/color][b][color=#00FFFF])[/color][/b]
 [b][color=#80FF00])[/color][/b]
 [b][color=#80FF00]([/color][/b][color=BLUE]princ[/color][b][color=#80FF00])[/color][/b]
[b][color=#FF0000])[/color][/b]

HTH, M.R.

Edited by marko_ribar
code little changed
Posted

Thanks marko_ribar,works smooth.! now i have two LISPs for Center Line. good for cross checking.

One question instead of first selecting line one and then line two. can it be modified to select both lines at the same time? would be a big time saver.

Since a lot of zooming in and out , Panning, and picking individually is required in case there are thousands of lines to be picked.

Posted
Thanks marko_ribar,works smooth.! now i have two LISPs for Center Line. good for cross checking.

One question instead of first selecting line one and then line two. can it be modified to select both lines at the same time? would be a big time saver.

Since a lot of zooming in and out , Panning, and picking individually is required in case there are thousands of lines to be picked.

 

I won't think it will make things faster... You have to decide with your head what entities you should pick - must be correct offset pair and correct entity types on unlocked layers... If you select, you can have selection containing more than 2 entities and it also could have wrong offset pair if 2 entities in selection... It could be just slightly faster... I've added that you tap ENTER for 1 center offset, or input how much offsets user wants... And I think that now it's more adequate offset checking - through point...

Posted (edited)
Thanks marko_ribar,works smooth.! now i have two LISPs for Center Line. good for cross checking.

One question instead of first selecting line one and then line two. can it be modified to select both lines at the same time? would be a big time saver.

Since a lot of zooming in and out , Panning, and picking individually is required in case there are thousands of lines to be picked.

 

my attempt is only test for LINE (dxf 10 11) maybe need explode for testing


http://www.cadtutor.net/forum/showthread.php?88968-Endless-Centre-Lines&p=609662&viewfull=1#post609662
(setq *sd* 0.0) ; Multiple Offset to Center by paired lines 
(defun c:OFFCL (/ *error* ml m sd p1 2p e1 pair l en suml meanl oe dd)
;hanhphuc 13/10/2014
 
 (defun *error* (msg)
   (if	(not (wcmatch (strcase msg) "*CANCEL*,*EXIT*"))
     (princ (strcat "\nError: " msg))
     ) ;_ end of if
   (if	oe
     (setvar "cmdecho" oe)
     ) ;_ end of if
   (princ)
   ) ;_ end of defun
 (setq oe (getvar "cmdecho"))
 (command "_UNDO" "be")
 (setvar "cmdecho" 0)
 (mapcar 'set
  '(suml meanl)
  '(((lst / ans l)
     (setq
      ans
      (car lst)
      l
      (cdr lst)
      )
     (while
      l
      (setq
       ans
       (mapcar '(lambda (a b) (float (+ a b))) ans (car l))
       l
       (cdr l)
       )
      )
     ans
     )
    ((lst /)
     (mapcar '(lambda (c) (/ c (length lst))) (suml lst)) ;_ end of mapcar
     )
    ) ;_ end of list
  ) ;_ end of mapcar
 (grtext -1 "command: OFFCL")
 (if (and (setq e (car (entsel "\nPick matched layer entity..")))
   (setq _layer (cdr (assoc 8 (entget e))))
   ) ;_ end of and
   (setq sd  (getdist
	(strcat "\nIgnore short length, approx < Between 0.0 to " (rtos *sd* 2 3) " > ? : ")
	) ;_ end of getdist
  m   ((lambda (lay minx / ss l 2p d ap tmp l lst mp)
	 (setq ss (ssget ":L" (list '(0 . "LINE") (cons 8 lay))))
	 (if ss
	   (foreach line (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
	     (setq l   (entget line)
		   2p  (mapcar ''((p) (cdr (assoc p l))) '(10 11))
		   2p  (apply 'if
			      (vl-list*	(apply '<= (mapcar 'abs (cdr (reverse (apply 'mapcar (cons '- 2p))))))
					(mapcar ''((f) (vl-sort 2p ''((a b) (> (f a) (f b))))) (list car cadr))
					) ;_ end of vl-list*
			      ) ;_ end of apply	      
		   d   (apply 'distance 2p)
		   tmp ; unused variable, just for update elist by entmod inside setq expression 
		       (mapcar ''((u v) (setq l (subst (cons v u) (assoc v l) l)) (entmod l)) 2p '(10 11)) ; _ end of mapcar
		   lst (if (> d minx)
			 (cons (vl-list* line (mapcar ''((a b) (* (+ a b) 0.5)) (car 2p) (cadr 2p))) lst)
			 lst
			 ) ;_ end of if
		   ) ;_ end of setq
	     (if (and (<= d minx))
	       (entmakex (list '(0 . "CIRCLE")
			       '(8 . "SHORT_BROKEN") ; Layer of short broken lines
			       '(62 . 6)
			       (cons 10 (meanl 2p))
			       (cons 40 *sd*)
			       ) ;_ end of list
			 ) ;_ end of entmake
	       ) ;_ end of  
	     ) ;_ end of foreach
	   ) ;_ end of if
	 lst ;_ retval= m
	 ) ;_ end of list
	_layer ; <--- Picked Layer 
	(setq *sd* (if sd
		     sd
		     *sd*
		     ) ;_ end of if
	      ) ;_ end of setq
	) ; middle point list
  len (length m)
  ) ;_ end of setq
   ) ;_ end of if
 (repeat (if (= (logand len) 1)
    (1- len)
    len
    ) ; m= (en midpt)
   (setq p1   (cdr (car m)) ; 1st midpt
  e1   (caar m) ; 1st ename
  pair (car (vl-sort (setq d (mapcar '(lambda (x)
					(list (car x) ;ename
					      (cdr x) ;point
					      (distance p1 (cdr x))
					      ) ;_ end of list
					) ;_ end of lambda
				     (cdr m)
				     ) ;_ end of mapcar
			   ) ;_ end of setq
		     ''((a b) (< (caddr a) (caddr b)))
		     ) ;_ end of vl-sort
	    ) ;_ end of car
  ) ;_ end of setq
   (if	(and p1 pair) ;_ end of and
     (setq
    m  (vl-remove-if ''((x) (= (car x) (car pair))) (cdr m))
    l  (mapcar '(lambda (i) (mapcar ''((e) (cdr (assoc i (entget e)))) (list e1 (car pair))))
	       '(10 11)
	       ) ;_ end of mapcar
    en (entmakex (vl-list* '(0 . "LINE")
			   '(8 . "CENTER")
			   '(62 . 1)
			   (mapcar ''((x i) (cons i (meanl x))) l '(10 11))
			   ) ;_ end of vl-list*
		 ) ;_ end of entmakex
    dd (mapcar ''((e) (vla-get-length (vlax-ename->vla-object e))) (list en e1 (car pair))) 

    ) ;_ end of setq
     ) ;_ end of if
  (if (< (car dd) (* 0.25 (apply '+ (cdr dd))))
    (redraw (entmakex (list '(0 . "CIRCLE")
		     '(8 . "BAD CENTER")
		     '(62 . 5)
		     (cons 40 (* 0.25(car dd)))
		     (cons 10 (meanl (mapcar ''((i) (cdr (assoc i (entget en)))) '(10 11)))) ;_ end of mapcar
		     ) ;_ end of list
	       ) ;_ end of entmakex
     3
     ) ;_ end of redraw
    ) ;v1.1
   
     (redraw en 3)
     
   ) ;_ end of repeat
 (command "_undo" "e")
 (setvar "cmdecho" oe)
 (princ)
 ) ;_ end of defun

(princ "\nOffset Center Line. Command: OFFCL")
(princ)

 

maybe need to approach ARC... (after exploding some are ARC)

 

Selections need be careful due to it compares each pair , so must not select all at one time

select partially better. Marko's routine works on parallel ,so i try my best to make it more generic which allow not parallel lines.

 

command: OFFCL

1.pick the entity for matched layer

2.dist to be ignored during compare

3.select Lines

 

 

offcl.gif

Edited by hanhphuc
image & comments
Posted

My Gosh!!! hanhphuc this is incredible. Sad Iam Unable to make it work. Iam using Acad 2013.

Here is what iam doing.

1. I Didn't want any confusion regarding layers so brought everything to one layer.

2. Didn't want any confusion regarding type of lines so used MPEDIT and converted all lines,Arc's to Polylines. so now i have only Polylines in the drawing.

3. Apploaded the LISP

4. Entered OFFCL

5. Program asks Pick matched layer entity..

6. At this point i dont know what iam suppose to do exactly. so i pick any random line

7. Program asks . Ignore short length, approx ? :

8. at this Point i don't know what iam suppose to do. i just select two points along length of a random line like shown in your demo in the GIF.

9. No the cursor changes and program asks to select object. i try selecting like shown GIF above. but nothing is getting selected. and no center lines created.

Posted

hi suryacad, if the joined LWpolyline has difference vertex that would be quite challenging that's why currently i just test for LINE, i'll try to tweak for arc offset soon.

 

[QUOT]

7. Program asks . Ignore short length, approx ? :

[/QUOT]

This is just approximate length to be ignore. you can click on sceen slightly wider than the width of wall. ie: shorter lines would not be used for offset

 

attach the exploded dwg for test.

HTH

new block_exploded.dwg

Posted

Thanks so much hanhphuc. i was wrong in trying to work with polylines works smooth with Lines, Wonderful.

Thanks Again :notworthy:

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