Jump to content

Need little modification for this lisp


cadamrao

Recommended Posts

[ATTACH]35718[/ATTACH]hello!

 

I need little modification for this lisp to easy change my beam schedule beam marking name. I need to increment order of CSHB1.After selection of text; I'm looking pick first point means copy the text from below CSHB1 redline left side endpoint to destination point (Left Click to Copy Increment) at respective left side endpoint of RC beam size (as per specified RC beam size rows values)

 

 

thanks for the support&value of ur time

 

Venki

BEAM.dwg

NUMBER INC (NIE).lsp

Link to comment
Share on other sites

Without taking a look at your code and here is my routine to renumber the marketing name if it has a number at the end of its string .

 

First select the text then specify the distance between texts and finally the whole distance .

 

(defun c:TesT (/ s p p1 e n v st str)
;;;; Tharwat 04. July. 2012 ;;;;
 (setq i (if i
           d
           (getvar 'textsize)
         )
 )
 (cond
   (
    (not (setq s (ssget "_+.:S" '((0 . "TEXT,MTEXT")))))
   )
   (
    (not
      (if (and
            (setq
              n
               (last (vl-string->list
                       (setq
                         v (cdr (assoc 1 (setq e (entget (ssname s 0)))))
                       )
                     )
               )
            )
            (numberp (read (chr n)))
          )
        (setq n (atoi (chr n)))
      )
    )
    (princ "\n Last character is not number !! ")
   )
   (
    (not (if (progn (initget 6)
                    (setq d
                           (cond
                             ((getdist (strcat "\n Specify distance between texts < "
                                               (rtos i 2)
                                               " > :"
                                       )
                              )
                             )
                             (t i)
                           )
                    )
             )
           (setq i d)
         )
    )
   )
   (
    (not (and (setq p (getpoint "\n Specify end point :"))
              (setq p1 (getpoint "\n Next point :" p))
         )
    )
   )
   (t
    (progn
      (setq str (substr v 1 (1- (strlen v))))
      (repeat (fix (/ (distance p p1) d))
        (entmakex
          (list '(0 . "TEXT")
                (cons 10 (setq st (trans (polar p (angle p p1) d) 1 0)))
                (cons 11 st)
                (assoc 40 e)
                (cons 1 (strcat str (itoa (setq n (1+ n)))))
          )
        )
        (setq p st)
      )
    )
   )
 )
 (princ)
)

Link to comment
Share on other sites

(Defun c:CMI  (/ parseStr _inccopy TxtObj fp sp dst ang gr code data)
;;;    pBe July 2012    ;;;
     (vl-load-com)
     (defun parseStr  (str / strA pr v)
           (setq strA (if (zerop (atoi (setq v str)))
                            (setq pr (vl-string-right-trim
                                           "0123456789"
                                           str))
                            (progn (setq pr "") v)))
           (strcat pr
                   (itoa (1+ (atoi (if (eq strA str)
                                         strA
                                         (vl-string-trim
                                               strA
                                               str))))))
           )
     (defun _inccopy  (e p1 p2 / st)
           (vlax-invoke
                 (setq e (vla-copy e))
                 'move p1 p2)
           (vla-put-textstring e
                 (parseStr (vla-get-textstring e)))
           e
           )
     (cond ((and
                  (setq TxtObj (ssget "_:L:S:E" '((0 . "TEXT"))))
                  (setq TxtObj (vlax-ename->vla-object
                                     (ssname TxtObj 0)))
                  (setq fp (getpoint "\nPick first point: "))
                  (setq sp (getpoint fp "\nPick second point: "))
                  (setq dst (distance
                                  (setq fp (trans fp 1 0))
                                  (setq sp (trans sp 1 0)))
                        ang (angle fp sp))
                  (setq TxtObj (_inccopy TxtObj  fp  sp))
                  (print)
                  (while
                        (progn
                              (princ
                                    "\rPress Space Bar to Copy Increment/Left click  to move Previous object/Undo:")
                              (setq gr   (grread t 15 0)
                                    code (car gr)
                                    data (cadr gr)
                                    )
                              (cond
                                    [color=blue]((and (= 2 code)
                                          (member  data '(85 117)))
                                     (vlax-invoke TxtObj 'move sp fp) T
                                     )[/color]
                                    ((and (= 2 code)
                                          (= data 32))
                                     (setq TxtObj (_inccopy TxtObj fp sp)
                                           fp     sp
                                           sp     (polar sp ang dst))
                                     )
                                    ((= 3 code)
                                     (vlax-invoke TxtObj 'move fp sp)
                                     (setq fp sp
                                           sp (polar sp ang dst))
                                     T
                                     )
                                    ((= 5 code) T)
                                    )
                              )
                        )
                  )
            )
           )
     (princ)
     )

 

Command: CMI

Select objects:

Pick first point:

Pick second point:

Press Space Bar to Copy Increment/Left click to move Previous object/Undo:

 

NOTE:

It needs getting use. you'll know it when you see it. :)

Edited by pBe
Add UNDO
Link to comment
Share on other sites

Interesting pBe . :thumbsup:

 

It is good to have the object name Mtext with Text into your selection set . :)

 

Thanks.

 

I agree, MTEXT option would be nice, but i may need to put an additional sub to handle Charactrer formatting with this http://www.lee-mac.com/unformatstring.html , (kudos to LM), Might as well include as soon as the OP gives the A-OK

 

You will notice that i opted to use move/copy rather than creating the TEXT entity, that way you dont need to deal with properties and the like to match the selected object.

 

Apprecitae your comments tharwat

Thank you for that :)

 

Cheers dude

Link to comment
Share on other sites

Thanks you sir,added tikka masala to CMI ;very nice.

 

Thanks a lot

venki

 

 

 

(Defun c:CMI  (/ parseStr _inccopy TxtObj fp sp dst ang gr code data)
;;;    pBe July 2012    ;;;
     (vl-load-com)
     (defun parseStr  (str / strA pr v)
           (setq strA (if (zerop (atoi (setq v str)))
                            (setq pr (vl-string-right-trim
                                           "0123456789"
                                           str))
                            (progn (setq pr "") v)))
           (strcat pr
                   (itoa (1+ (atoi (if (eq strA str)
                                         strA
                                         (vl-string-trim
                                               strA
                                               str))))))
           )
     (defun _inccopy  (e p1 p2 / st)
           (vlax-invoke
                 (setq e (vla-copy e))
                 'move p1 p2)
           (vla-put-textstring e
                 (parseStr (vla-get-textstring e)))
           e
           )
     (cond ((and
                  (setq TxtObj (ssget "_:L:S:E" '((0 . "TEXT"))))
                  (setq TxtObj (vlax-ename->vla-object
                                     (ssname TxtObj 0)))
                  (setq fp (getpoint "\nPick first point: "))
                  (setq sp (getpoint fp "\nPick second point: "))
                  (setq dst (distance
                                  (setq fp (trans fp 1 0))
                                  (setq sp (trans sp 1 0)))
                        ang (angle fp sp))
                  (setq TxtObj (_inccopy TxtObj  fp  sp))
                  (print)
                  (while
                        (progn
                              (princ
                                    "\rPress Space Bar to Copy Increment/Left click  to move Previous object/Undo:")
                              (setq gr   (grread t 15 0)
                                    code (car gr)
                                    data (cadr gr)
                                    )
                              (cond
                                    [color=blue]((and (= 2 code)[/color]
[color=blue]                                          (member  data '(85 117)))[/color]
[color=blue]                                     (vlax-invoke TxtObj 'move sp fp) T[/color]
[color=blue]                                     )[/color]
                                    ((and (= 2 code)
                                          (= data 32))
                                     (setq TxtObj (_inccopy TxtObj fp sp)
                                           fp     sp
                                           sp     (polar sp ang dst))
                                     )
                                    ((= 3 code)
                                     (vlax-invoke TxtObj 'move fp sp)
                                     (setq fp sp
                                           sp (polar sp ang dst))
                                     T
                                     )
                                    ((= 5 code) T)
                                    )
                              )
                        )
                  )
            )
           )
     (princ)
     )

 

Command: CMI

Select objects:

Pick first point:

Pick second point:

Press Space Bar to Copy Increment/Left click to move Previous object/Undo:

 

NOTE:

It needs getting use. you'll know it when you see it. :)

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