REQUEST TO MAKE A LISP

REQUEST TO MAKE A LISP

smallƑish
Advocate Advocate
285 Views
2 Replies
Message 1 of 3

REQUEST TO MAKE A LISP

smallƑish
Advocate
Advocate

Let's say I have a line, and a stretchable dynamic block too. Just need to pick staring point, end point, angle of the line. And replace the line with the block and stretch from start point to end point. Will that be possible with lisp ? 

0 Likes
286 Views
2 Replies
Replies (2)
Message 2 of 3

Sea-Haven
Mentor
Mentor

This is Part one of your other request. Add tee at corner. You should just run with one post with both tasks. 

 

Adding elbow to pipe - Autodesk Community

 

Have you done a google about drawing pipes and fittings there is software out there. Look in Autodesk Appstore.

0 Likes
Message 3 of 3

smallƑish
Advocate
Advocate

 

  • Selects a line and determines its start, midpoint, and end.
  • Calculates the angle of the line based on the start and end points.
  • Inserts the block PIPE at the midpoint of the line with the correct rotation.
  • Stretches the block so that its endpoints align with the start and end of the line.

This is what i m trying but somthing wrong here.   

 

(defun c:linetopipe (/ ent start end mid ang insPt blkName blkScale)
  (setq blkName "PIPE")  ;; Block name

  ;; Select the line
  (setq ent (car (entsel "\nSelect a line: ")))

  (if (and ent (eq (cdr (assoc 0 (entget ent))) "LINE"))
    (progn
      ;; Get start, midpoint, and end of the line
      (setq start (cdr (assoc 10 (entget ent))))
      (setq end (cdr (assoc 11 (entget ent))))
      (setq mid (mapcar '(lambda (a b) (/ (+ a b) 2)) start end)) ;; Midpoint
      
      ;; Calculate angle of the line
      (setq ang (angle start end))

      ;; Insert block at midpoint with calculated angle
      (setq insPt mid)
      (command "_.INSERT" blkName insPt "1" "1" ang)

      ;; Get last inserted block
      (setq blk (entlast))

      (if blk
        (progn
          ;; Modify block's stretch points to fit the line
          (command "_.STRETCH" "_C" blk "" start end)
        )
      )
    )
    (princ "\nSelected entity is not a line.")
  )
  (princ)
)

 

 

 

 

0 Likes