+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Forum Newbie
    Discipline
    Civil
    Using
    AutoCAD 2018
    Join Date
    Jun 2018
    Posts
    3

    Default Move selected text to polyline vertexes

    Registered forum members do not see this ad.

    Hi, is it possible to make lisp routine which will move multiple selected texts to polyline vertexes. At first vertex i want text with smallest x coordinate and so on Sorry for my english.

    If its too complicated can you guys make routine which will do this: I pick polyline than text and that text moves to 1st vertex than i select another text and that text go to secound vertex and so on?

  2. #2
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,225

    Default

    Hi,
    Welcome to CADTutor.

    This must be fun to write, so can you upload a sample drawing showing before and after running the program on objects?

  3. #3
    Forum Newbie
    Discipline
    Civil
    Using
    AutoCAD 2018
    Join Date
    Jun 2018
    Posts
    3

    Default

    Quote Originally Posted by Tharwat View Post
    Hi,
    Welcome to CADTutor.

    This must be fun to write, so can you upload a sample drawing showing before and after running the program on objects?
    Hi, tnx

    I uploaded sample file here --> https://ufile.io/mx3ha

  4. #4
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,225

    Default

    Its recommended to upload your files via this website for more secured issues.

    Hit on the button 'Go Advanced' on the right side hand below to be able to attach your drawing.

    Time to go to bed now, its too late here so would take a look tomorrow.

  5. #5
    Forum Newbie
    Discipline
    Civil
    Using
    AutoCAD 2018
    Join Date
    Jun 2018
    Posts
    3

    Default

    File sample is in attachment.

    Thank you for fast reply and good night.
    Attached Files

  6. #6
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,454

    Default

    I haven't lisping for a while, heres something (will work on horizontal lwpolyline, as it sorts the points by X coordinate) :
    Code:
    (defun C:test ( / vr SS GetCen i o pL )
      (and 
        (setq vr 
          ( (lambda (f) (setvar 'errno 0) (f nil nil))
            (lambda ( e enx ) 
              (cond 
                (enx (apply (function append) (mapcar (function (lambda (x) (if (= 10 (car x)) (list (append (cdr x) '(0.)))))) enx)) )
                (e (f nil (member '(0 . "LWPOLYLINE") (entget e))) ) 
                ( (= 52 (getvar 'errno)) nil)
                ( (= 7 (getvar 'errno)) (setvar 'errno 0) (f e nil))
                ( (f (car (entsel "\nPick the polyline <exit>: ")) nil) )
              )
            )
          )
        )
        (setq SS (ssget "_:L-I" '((0 . "TEXT"))))
        (progn
          ; (entmakex (list '(0 . "POINT")(cons 10 (GetCen (vlax-ename->vla-object (car (entsel)))))))
          (defun GetCen ( o / ll ur )
            (vla-GetBoundingBox o 'll 'ur)
            (apply 'mapcar (cons '(lambda (a b) (* 0.5 (+ a b))) (mapcar 'vlax-safearray->list (list ll ur))))
          )
          (repeat (setq i (sslength SS))
            (setq pL (cons (list (GetCen (setq o (vlax-ename->vla-object (ssname SS (setq i (1- i)))))) o) pL))
          )
          (foreach x
            (mapcar 'cons
              (vl-sort vr (function (lambda (a b) (< (car a) (car b)))))
              (vl-sort pL (function (lambda (a b) (< (caar a) (caar b)))))
            )
            (princ (apply (function (lambda (a b c) (vlax-invoke a 'Move b c))) (reverse x)))
          )
        )
      )
      (princ)
    )
    (vl-load-com) (princ)

  7. #7
    Super Member hanhphuc's Avatar
    Using
    AutoCAD 2007
    Join Date
    Apr 2013
    Location
    Happy Garden
    Posts
    710

    Default

    Quote Originally Posted by Grrr View Post
    I haven't lisping for a while, heres something (will work on horizontal lwpolyline, as it sorts the points by X coordinate) :
    Code:
    (defun C:test ( / vr SS GetCen i o pL )
    
    (f nil nil)
    @grrr nice recursive instead of ssget filter nomutt=1 in while loop
    _$ ( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" )
    ; error: too many arguments

  8. #8
    Senior Member ketxu's Avatar
    Computer Details
    ketxu's Computer Details
    Operating System:
    Sorry, my English not well :(
    Computer:
    Sorry, my English not well :(
    Motherboard:
    Sorry, my English not well :(
    CPU:
    Sorry, my English not well :(
    RAM:
    Sorry, my English not well :(
    Graphics:
    Sorry, my English not well :(
    Primary Storage:
    Sorry, my English not well :(
    Secondary Storage:
    Sorry, my English not well :(
    Monitor:
    Sorry, my English not well :(
    Using
    AutoCAD 2007
    Join Date
    Sep 2010
    Location
    Sorry, my English not well :(
    Posts
    205

    Default

    Quote Originally Posted by hanhphuc View Post
    @grrr nice recursive instead of ssget filter nomutt=1 in while loop
    Ohh... i'm feeling more difficult to understand ^^

  9. #9
    Super Member hanhphuc's Avatar
    Using
    AutoCAD 2007
    Join Date
    Apr 2013
    Location
    Happy Garden
    Posts
    710

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by ketxu View Post
    Ohh... i'm feeling more difficult to understand ^^
    hjj i came across undocumented var 'nomutt from Lee's function. credits to Lee.
    Code:
    ((lambda (/ s ov)
       (setq ov (getvar 'nomutt))
       (setvar 'nomutt 1)
       (while (not s)
         (princ "\rPick the polyline <exit>: ")
         (setq s (ssget ":E:S+." '((0 . "LWPOLYLINE"))))
         ) (setvar 'nomutt ov)
       ((lambda (f)  (f  (entget (ssname s 0))))
         '(( l)
           (if
    	(setq l (member (assoc 10 l) l))
    	(cons (append (cdar l)'(0.00)) (f (cdr l)))
    	)
           )
         )
       ) 
     )
    To suppress unwanted command ecdo, using ssget filter ":S" which emulating entget function only single entity selected so i don't need :
    "Select objects : "
    _$ ( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" )
    ; error: too many arguments

Similar Threads

  1. Replies: 16
    Last Post: 17th Jan 2015, 08:05 am
  2. Breaking Polyline at Vertexes
    By notview in forum AutoLISP, Visual LISP & DCL
    Replies: 13
    Last Post: 30th Sep 2013, 05:30 am
  3. Encircle the vertexes of (two or more) selected polyline having a gap
    By notview in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 19th Apr 2013, 11:37 am
  4. move, align and rotate text to two selected points
    By toberino in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 9
    Last Post: 5th Nov 2012, 04:26 pm
  5. lisp to move largest room polyline to another layer for floor gross polyline
    By TheresaT in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 25th Aug 2010, 07:11 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts