Jump to content

offset increment numbering with change direction


exceed

Recommended Posts

; offset increment numbering with change direction - 2023.04.28 exceeds

(vl-load-com)
(defun c:WCOPY ( / ss util en ent alignpt obj originalnum basept ang deg dist rotateold rotateinput rotatememory newnewobj ss2 en2 ent2 alignpt2 counter)
  (sssetfirst nil)
  (setvar "cmdecho" 0)

  (setq counter 0)
  ;error control
  (defun *error* ( msg )
    (if (>= counter 1)
      (progn
        (setq alignpt2 (cdr (assoc 11 (entget (entlast)))))
        (if (= alignpt alignpt2)
          (progn 
            (vla-delete newnewobj)
            (princ "\n Temporary Object Deleted.")
          )
        )
      );end of progn
    );end of if
    (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
      (princ (strcat "\n Error: " msg))
    )

    (setvar 'cmdecho 1)
    (princ)
  )

  (setq util (vla-get-utility (vla-get-activedocument (vlax-get-acad-object))))
  (setq ss (ssadd))
  (princ "\n Select Original Number (Text) : ")
  (if (setq ss (ssget '((0 . "TEXT"))))
    (if (= (sslength ss) 1)
      (progn
        (setq en (ssname ss 0))
        (setq ent (entget en))
        (setq alignpt (cdr (assoc 11 ent)))
        (setq obj (vlax-ename->vla-object en))
        (setq originalnum (atoi (vl-princ-to-string (vlax-get-property obj 'TextString))))
        (setq basept (getpoint "\n Pick Base Point : "))
        (setq ang (angle basept alignpt))
        (setq deg (* 180.0 (/ ang pi)))
        (setq dist (distance basept alignpt))
        (cond 
          ((or (<= 315 deg) (< deg 45))
            (setq rotateold "D")
            (princ "\n Direction : Right")
          )
          ((and (<= 45 deg) (< deg 135))
            (setq rotateold "W")
            (princ "\n Direction : Up")
          )
          ((and (<= 135 deg) (< deg 225))
            (setq rotateold "A")
            (princ "\n Direction : Left")
          )
          ((and (<= 225 deg) (< deg 315))
            (setq rotateold "S")
            (princ "\n Direction : Down")
          )
        )
        (command "_tjust" ss "" "mc")
        (while (= 1 1)
        (setq rotateinput (strcase (getstring "\n Change Direction? Up(W), Down(S), Left(A), Right(D), Keep Previous Direction(SpaceBar)")))
        (if (= rotateinput "")
          (if (= rotatememory "")
            (progn 
              (setq rotateinput rotateold)
            )
            (progn
              (setq rotateinput rotatememory)
            )
          )
          (progn)
        )
        (princ "\n Direction : ")
        (princ rotateinput)
        (cond 
          ((= rotateinput "W") 
            (princ "Up(W) Selected.")
            (cond
              ((= rotateold "D")
                (setq newdeg (+ deg 90))
              )
              ((= rotateold "W")
                (setq newdeg deg)
              )
              ((= rotateold "A")
                (setq newdeg (- deg 90))
              )
              ((= rotateold "S")
                (setq newdeg (+ deg 180))
              )
              (t
                (setq newdeg deg)
              )
            )
          )
          ((= rotateinput "A")
            (princ "Left(A) Selected.")
            (cond
              ((= rotateold "D")
                (setq newdeg (+ deg 180))
              )
              ((= rotateold "W")
                (setq newdeg (+ deg 90))
              )
              ((= rotateold "A")
                (setq newdeg deg)
              )
              ((= rotateold "S")
                (setq newdeg (- deg 90))
              )
              (t
                (setq newdeg deg)
              )
            )
          )
          ((= rotateinput "S")
            (princ "Down(S) Selected.")
            (cond
              ((= rotateold "D")
                (setq newdeg (- deg 90))
              )
              ((= rotateold "W")
                (setq newdeg (+ deg 180))
              )
              ((= rotateold "A")
                (setq newdeg (+ deg 90))
              )
              ((= rotateold "S")
                (setq newdeg deg)
              )
              (t
                (setq newdeg deg)
              )
            )
          )
          ((= rotateinput "D")
            (princ "Right(D) Selected.")
            (cond
              ((= rotateold "D")
                (setq newdeg deg)
              )
              ((= rotateold "W")
                (setq newdeg (- deg 90))
              )
              ((= rotateold "A")
                (setq newdeg (+ deg 180))
              )
              ((= rotateold "S")
                (setq newdeg (+ deg 90))
              )
              (t
                (setq newdeg deg)
              )
            )
          )
          (t
            (setq newdeg deg)
          )
        )
        (setq ang (* pi (/ (+ newdeg 180) 180)))
        ;(princ ang)
        (setq basept (polar alignpt ang dist))
        ;(princ basept)

        (setq newnewobj (vla-copy obj))
        (setq counter (+ counter 1))
        (setq ss2 nil)
        (setq ss2 (ssadd))
        (setq en2 (vlax-vla-object->ename newnewobj))
        (ssadd en2 ss2)
        (vlax-put-property newnewobj 'TextString (+ originalnum 1))
        (setq ent2 (entget en2))

        (command "_move" ss2 "" basept pause)



        ;(command "_pasteclip" pause)

        (setq originalnum (+ originalnum 1))
        (setq rotatememory rotateinput)


        
        );end of while
      )
      (progn
        (princ "\n Select 1 Text Only.")
        (c:WCOPY)
      )    
    )
  )

  (setvar "cmdecho" 1)
  (princ)
)

 

 

Long time no see.

this uses command instead of grread.

because I want to be able to see the preview & using osnap. Move Command is easy way for me.

 

Command : WCOPY

1. Select 1 Text (Number)

2. Pick Base Point

3. lisp check your Direction

4. Select Direction - Press W/A/S/D or SpaceBar

5. Pick Target Point

2023-04-28 13;48;41.gif

  • Like 3
Link to comment
Share on other sites

Very nice but why input the direction can you not imply the quadrant for the text by the pick point ?

 

If number is nil ie 1st go ask for number maybe ? If number is on a layer then read all text and get last number and ask use this number ? 

 

If object is a block etc then can get bounding box so know distance from say centre/insert point. 

 

Had something simillar will try to find did number in a bubble square or circle with a line connecting point.

 

  • Like 1
Link to comment
Share on other sites

On 4/30/2023 at 9:29 AM, BIGAL said:

Very nice but why input the direction can you not imply the quadrant for the text by the pick point ?

 

If number is nil ie 1st go ask for number maybe ? If number is on a layer then read all text and get last number and ask use this number ? 

 

If object is a block etc then can get bounding box so know distance from say centre/insert point. 

 

Had something simillar will try to find did number in a bubble square or circle with a line connecting point.

 

 

Thank you for giving me some good cases to think about.😀

 

I made it as simple as possible because I often encounter blocks with various shapes of symbols,

non-block symbols, or blocks with reference points in the wrong place when doing various projects.😂

 

improvement point I think is to copy the text and at least one non-text together to cope with the unusual bubble shape

that is unpredictable. Because the projects have things that are not circles or hexagons or wipeout, In case of wipeout,

it seems difficult because have to consider the draw order as well.

 

Edited by exceed
Link to comment
Share on other sites

You are right, a real odd block with gaps etc makes selecting a point to use hard, CIV3D has shrinkwrap and there is a commercial program to create a boundary around objects so a pointer line could be added and trimmed at invisible edge.

image.png.2dfc74ae16637471e3afa4391ec34c3b.png

 

Used this on point num bubble where line is trimmed to the bubble but can be any direction.

image.png.5b9fb15de5216ded549a266ddd1a7136.png

 

It may be for "often encounter blocks with various shapes of symbols" a couple of different styles of labelling. But again trimming around a block shape is hard. 

 

A lot of people are looking for this so very useful.

 

 

Edited by BIGAL
  • Like 1
Link to comment
Share on other sites

I'd be tempted to make the new text with entmake rather than copy obj - just in case the user cancels the LISP before the paste part, you'll still have the incremented copied text at the original location?

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