Jump to content

Move selected text to polyline vertexes


drdownload18

Recommended Posts

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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

Link to comment
Share on other sites

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 : "

Link to comment
Share on other sites

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