Jump to content

Change a length of line by feeding a new end point to the association list.


Recommended Posts

Posted

I can get the Association list of a line with  entget .

Please help me feed to new values to this list.

Posted (edited)

entget returns what are known as dxf codes.

 

lines, arc, circles, and other all follow a pattern. these lisp will output to command prompt.

;;----------------------------------------------------------------------------;;
;; Dump all DXF Group Data             
(defun C:DumpIt (/ ent)
  (while (setq ent (car (entsel "\nSelect Entity to Dump")))
    (mapcar 'print (entget ent '( "*")))
  )
  (princ)
)
;;----------------------------------------------------------------------------;;
;; Dump All Visual Lisp Methods and Properties for Selected Entity
(defun C:VDumpIt (/ ent)
  (while (setq ent (car (entsel "\nSelect Entity to Dump")))
    (vlax-Dump-Object (vlax-Ename->Vla-Object ent) t)
  )
  (princ)
)

 

 

Using entsel returns a point and an entity name. from that you can run entget and check if its a line. pick the endpoint closest to the selection point. then use entmod and entupd to update the line. or you could delete the line and remake it with entmakex with the newpoint.

;;----------------------------------------------------------------------------;;
;; Extend line to new point.
;; https://www.cadtutor.net/forum/topic/98936-change-a-length-of-line-by-feeding-a-new-end-point-to-the-association-list/
(defun c:EXTLINE ( / sel ent pick line sp ep newpt)
  (if (setq sel (entsel "\nSelect line near the end to extend: "))
    (progn
      (setq ent (car sel)
            pt (cadr sel) ;point from entsel
            line (entget ent)
      )
      (if (= (cdr (assoc 0 line)) "LINE")
        (progn
          (setq sp (cdr (assoc 10 line))) ;start point
          (setq ep (cdr (assoc 11 line))) ;end point of line
          (if (< (distance pt sp) (distance pt ep)) ;which point is closer to the entsel point
            (setq newpt (getpoint ep "\nSpecify new endpoint: ")  
                  line (subst (cons 10 newpt) (assoc 10 line) line)
            )
            (setq newpt (getpoint sp "\nSpecify new endpoint: ")
                  elist (subst (cons 11 newpt) (assoc 11 line) line)
            )
          )
          (entmod line)
          (entupd ent)
        )
        (prompt "\nSelected entity is not a LINE.")
      )
    )
  )
  (princ)
)

 

Edited by mhupp
Added notes to lisp

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