Author Topic: Auto Note Numbering Routine F1...  (Read 1501 times)

0 Members and 1 Guest are viewing this topic.

akdrafter

  • Guest
Auto Note Numbering Routine F1...
« on: July 25, 2006, 08:54:17 PM »
Hello All,

AutoCAD 2007
No Verts

I am trying to write a routine that will take a number a user enters and add it to the left of the picked text. What I have is a line of notes that may be whatever justification and I want to add the note number to the left.

ie....

1. Yadda Yadda Yadda
2. Yadda Yadda Yadda
3. Yadda Yadda Yadda

Yes, the #. and the note are separate pieces of text.

Right now the routine does not increment the number. For now I am just trying to get the correct placement of the new #. to the left of the picked text. As usual... I am clueless.

You can see that if the text is not L (default), TL, ML or BL then the routine simply quits. I know, I should inform the user a little more than just saying bye, but I don't need over complication. If it ain't right then it ain't right. The user should then use some basic drafting skills and fix it. Dog gone it. :-) Once we get through the thousands of details we have and get a truly "justified" (middle left) set of notes to work with the justification issue is just that... an issue.

Yes, it is crude and only in plain ol Lost In Stupid Parenthesis and I would prefer NOT to use vlisp or vba.

Many thanks for any assistance anyone can give me.

So, enough rambling.... What I have so far....

Code: [Select]
;;;
;;; NOTE.lsp
;;;
;;; Note Number Pick and Increment Routine
;;;
;;; Degrees to Radians Function
;;;
(defun DTR (a)
(* PI (/ a 180.0))
)
;;;
(defun c:NOTE (/ DOT TXT3 ENT1 ENT2 ENT3 HJ VJ NEWJ HT ROTANG PT1 PT2)
;;;
;;; Enter The Begining Number To Use And Add the "dot"
;;;
(setq TXT1 (getint "\nEnter Note Number: ")); get the initial number
(setq TXT2 (itoa TXT1)); convert it to a string
(setq DOT (substr ".DOT" 1 1)); only way I could find to get a "dot" into a string
(setq TXT3 (strcat TXT2 DOT)); string TXT2 and DOT together to form a single string

;;;********** Pick and Extract Selected Text Information **********
;;; Pick Text
;;;
(setq ENT1 (entsel "\nSelect The Note Line of Text: ")); Select the text line and it's point info
(while (= ENT1 nil); if we did not select anything then
(alert "No Text Selected... Select Again"); alert the user
(setq ENT1 (entsel "\nSelect The Note Line of Text: ")); and ask again
); ok, we got something
(setq ENT2 (car ENT1)); get the first element of the list
(setq ENT3 (entget ENT2)); get the entity name we are going to be querying
;;;
;;; Extract Selected Text Information
;;;
(setq HJ (cdr (assoc 72 ENT3))); Horizontal point for use below
(setq VJ (cdr (assoc 73 ENT3))); Vertical point for use below
;;;
;;; Extract Selected Text Height
;;;
(setq HT (cdr (assoc 40 ENT3))); Height
;;;
;;; Extract Selected Text Rotation Angle
;;;
(setq ROTANG (cdr (assoc 50 ENT3))); Rotation Angle
;;;
;;; Extract Start Point of Selected Text and Set Point For New Text
;;;
;;; I am pretty certain the line below is what is not working correctly
;;;
(setq PT1 (cadr ENT1))
(setq PT2 (polar PT1 (DTR 180) 4))
;;;
;;;********** END ***** Pick and Extract Selected Text Information ***** END **********
;;;
(cond
((and (= VJ 0)(= HJ 0))(command ".text" PT2 HT ROTANG TXT3))
((and (= VJ 0)(= HJ 1))(princ "\nCenter Justified Text...Bye"))
((and (= VJ 0)(= HJ 2))(progn (princ "\nRight Justified Text...Bye")(command)))
((and (= VJ 0)(= HJ 3))(progn (princ "\nAligned Justified Text...Bye")(command)))
((and (= VJ 0)(= HJ 4))(progn (princ "\nMiddle Justified Text...Bye")(command)))
((and (= VJ 0)(= HJ 5))(progn (princ "\nFit Justified Text...Bye")(command)))
((and (= VJ 1)(= HJ 0))(command ".text" "J" "BL" PT2 HT ROTANG TXT3))
((and (= VJ 1)(= HJ 1))(progn (princ "\nBottom Center Justified Text...Bye")(command)))
((and (= VJ 1)(= HJ 2))(progn (princ "\nBottom Right Justified Text...Bye")(command)))
((and (= VJ 2)(= HJ 0))(command ".text" "J" "ML" PT2 HT ROTANG TXT3))
((and (= VJ 2)(= HJ 1))(progn (princ "\nMiddle Center Justified Text...Bye")(command)))
((and (= VJ 2)(= HJ 2))(progn (princ "\nMiddle Right Justified Text...Bye")(command)))
((and (= VJ 3)(= HJ 0))(command ".text" "J" "TL" PT2 HT ROTANG TXT3))
((and (= VJ 3)(= HJ 1))(progn (princ "\nTop Center Justified Text...Bye")(command)))
((and (= VJ 3)(= HJ 2))(progn (princ "\nTop Right Justified Text...Bye")(command)))
)
;;;
(princ)
);end defun

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Auto Note Numbering Routine F1...
« Reply #1 on: July 25, 2006, 11:35:20 PM »
Take a look at this routine
http://www.theswamp.org/index.php?topic=7003.0

Look at the functions box_text & box_mtext for anther way to get the text upper left corner & the text angle. From there you can place your number text.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.