Jump to content
drdownload18

Move selected text to polyline vertexes

Recommended Posts

drdownload18

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?

Share this post


Link to post
Share on other sites
Tharwat

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?

Share this post


Link to post
Share on other sites
drdownload18
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

Share this post


Link to post
Share on other sites
Tharwat

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.

Share this post


Link to post
Share on other sites
drdownload18

File sample is in attachment.

 

Thank you for fast reply and good night. :)

Need lisp.dwg

Share this post


Link to post
Share on other sites
Grrr

I haven't lisping for a while, heres something (will work on horizontal lwpolyline, as it sorts the points by X coordinate) :

(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)

Share this post


Link to post
Share on other sites
hanhphuc
I haven't lisping for a while, heres something (will work on horizontal lwpolyline, as it sorts the points by X coordinate) :

(defun C:test ( / vr SS GetCen i o pL )

[b][color="red"](f nil nil)[/color][/b]

 

@grrr nice recursive instead of ssget filter nomutt=1 in while loop :)

Share this post


Link to post
Share on other sites
ketxu
@grrr nice recursive instead of ssget filter nomutt=1 in while loop :)

Ohh... i'm feeling more difficult to understand ^^

Share this post


Link to post
Share on other sites
hanhphuc
Ohh... i'm feeling more difficult to understand ^^

 

hjj i came across undocumented var 'nomutt from Lee's function. credits to Lee. :)

((lambda (/ s ov)
  (setq ov (getvar 'nomutt))
  (setvar 'nomutt 1)
  (while (not s)
    (princ[color="purple"] "\rPick the polyline <exit>: "[/color])
    (setq s (ssget ":E:S+." '((0 . "LWPOLYLINE"))))
    ) (setvar 'nomutt ov)
  ((lambda (f)  (f  (entget (ssname s 0))))
    '(( l)
      (if
(setq l (member (assoc [color="red"]10[/color] l) l))
(cons (append (cdar l)[color="red"]'(0.00)[/color]) (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 : "

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×