Insert block along arc or polyline

Discussion in 'AutoCAD' started by Chip Harper, Mar 15, 2005.

  1. Chip Harper

    Chip Harper Guest

    Can anyone point me to an example for inserting a block multiple times along
    an arc or polyline?
     
    Chip Harper, Mar 15, 2005
    #1
  2. Chip Harper

    Gary Fowler Guest

    ;;; INSBLOCK.LSP A program to insert a block at a
    ;;; specified distance along a polyline. The block
    ;;; is aligned with the tangent of the polyline.
    ;;; by Tony Hotchkiss


    Go to cadalyst.com
     
    Gary Fowler, Mar 15, 2005
    #2
  3. Chip Harper

    WILLIE Guest

    why not look at the measure command in autocad
     
    WILLIE, Mar 15, 2005
    #3
  4. Chip Harper

    Jeff Mishler Guest

    measure? divide?
     
    Jeff Mishler, Mar 15, 2005
    #4
  5. Chip Harper

    Chip Harper Guest

    Gary, I found ...

    ;;CADALYST 11/03 AutoLISP Solutions INSBLK.LSP
    ;;(c) 2003 Tony Hotchkiss
    ;;; INSBLK.LSP Insert blocks as specified in an external file. The ;;;
    ;;; file can be edited by adding new block information. ;;;

    Looked at everything Tony submitted but could not the one you identified. Do
    you have a copy, as this seems to be what I am looking for.
     
    Chip Harper, Mar 16, 2005
    #5
  6. Chip Harper

    Chip Harper Guest

    Not practical for what I need. I normally use Robert's flex lisp to produce
    flex duct but I have a requirement that all ducts be two line and to scale.
    So I am thinking about inserting a block along an arc while rotating to draw
    the flex. I'm hoping to find a snip of code that I can use. Another thought
    is to offset an arc and change the linetype to zigzag but I'm not too
    thrilled with how it looks.
     
    Chip Harper, Mar 16, 2005
    #6
  7. Chip,

    Here is a quick code, might help, you can easily adapted to suit:

    Code:
    
    (vl-load-com)
    
    (defun C:TEST  (/ obj len d dis dif lst)
    
    (setq obj (vlax-ename->vla-object (car (entsel))))
    
    (setq	len
    (vlax-curve-getdistatparam obj (vlax-curve-getendparam obj)))
    
    (if (not def)
    (setq def 2.0))
    
    (setq d (getdist (strcat "\nDistance <" (rtos def) ">: ")))
    
    (if (not d)
    (setq d def)
    (setq def d))
    
    (setq dis d)
    
    (setq div (* n d))
    
    (setq n (fix (/ len d)))
    
    (setq dif (- len (* n d)))
    
    (repeat (1+ n)
    
    (command "point" (vlax-curve-getpointatdist obj d))
    
    (setq lst (cons (vlax-curve-getpointatdist obj d) lst))
    
    (setq d (+ dis d)))
    
    ;;;(foreach pt (vl-remove-if 'null lst) (command "point" pt))
    
    (princ))
    
    (princ)
    
     
    Luis Esquivel, Mar 16, 2005
    #7
  8. Chip Harper

    Gary Fowler Guest

    Code:
    ;;; INSBLOCK.LSP  A program to insert a block at a
    ;;; specified distance along a polyline.  The block
    ;;; is aligned with the tangent of the polyline.
    ;;; by Tony Hotchkiss
    (defun IBIT () (ins-block) (princ))
    (defun dxf (code ename) (cdr (assoc code (entget ename))))
    (defun ins-block  (/ n bname ss p-ent dist m i)
    ;;(setq bname (getstring "\n* Enter Block name: ")
    (defun GETBLOCKNAME  (/ bn ent)
    (setq bn (getstring "\n* Enter Block name, or <return> to select. *"))
    (if (= bn "")
    (progn (setq ent (entget (car (entsel)))) (setq bn (cdr (assoc 2
    ent))))))
    (setq bname (GETBLOCKNAME)
    ss    (ssget "X" (list (cons 2 bname)))
    p-ent nil)
    (if ss
    (setq n (sslength ss))
    (setq n 0)) ;_ end of if
    (prompt "\n* Select a polyline *")
    (while (not p-ent)
    (setq p-ent (car (entsel)))
    (if (not p-ent)
    (prompt "\n* No object selected; select again: *") ;_ end of prompt
    (progn
    (if (and (/= (dxf 0 p-ent) "POLYLINE") (/= (dxf 0 p-ent)
    "LWPOLYLINE")) ;_ end of and
    (progn (prompt "\n* Not a polyline, select again *") (setq p-ent
    nil)) ; progn
    ) ;_ end of if
    ) ;_ end of progn
    ) ;_ end of if
    ) ;_ end of while
    (setq dist (getreal "\n* Distance along polyline: "))
    (command "MEASURE" p-ent "B" bname "Y" dist)
    (setq ss (ssget "X" (list (cons 2 bname))))
    (if ss
    (progn (setq m (sslength ss)
    i (- m n)) ;_ end of setq
    (if (> i 0)
    (repeat (1- i) (entdel (entlast))) ; repeat
    (prompt "\n* No new blocks inserted. *")) ;_ end of if
    ) ; progn
    (prompt "\n* No blocks inserted. *")) ;_ end of if
    (princ)) ; insblock
    [code]
     
    Gary Fowler, Mar 16, 2005
    #8
  9. Chip Harper

    Gary Fowler Guest

    Why not use dline.lsp by AutoDesk. I have a modified version that will
    also do arcs if that will work for you.
     
    Gary Fowler, Mar 16, 2005
    #9
  10. I don't understand what you're trying to do that Measure (or Divide) won't
    do. It will put a Block instead of a point, and it will align it with the
    curvature (if you choose that option), and it will do it along an arc or
    polyline or line or spline (or circle, for that matter, but I've never seen
    flex duct in a circle). You just have to define your block carefully enough
    to make it come out looking the way you want. Am I missing something?
     
    Kent Cooper, AIA, Mar 16, 2005
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.