PDA

View Full Version : Help / guidance with using SSGET


MWKINCAID1
2007-03-10, 01:01 AM
I can't seem to get the text rotation part of the filter to work. can anyone turn on the light bulb.? thanks. mk

(SETQ TXX (SSGET "X" ((0 . "TEXT")(50 . "1.5708D")(8 . "60 VERT TEXT"))))

T.Willey
2007-03-10, 01:14 AM
In your rotation Number you have a letter. Plus you might need a fuzz factor.

aaronic_abacus
2007-03-10, 01:22 AM
Try this.



(SETQ TXX (SSGET "X" '((-4 . "<AND")(0 . "TEXT")(50 . 1.5708)(8 . "60 VERT TEXT")(-4 . "AND>"))))

MWKINCAID1
2007-03-10, 02:03 AM
Hi guys, i tried the latest option and had no success. I'm thinking my computer is getting cranky with me.
anyhow, I've tried the (SETQ TXX (SSGET "X" '((-4 . "<AND")(0 . "TEXT")(50 . 1.5708)(8 . "60 VERT TEXT")(-4 . "AND>"))))

and still that rotation is still getting me. I'm just trying to filter down to the text entities that are on a specific layer and have a specific rotation 90deg... Anyone have a work around. Thanks again, and thanks guys that have help me to this point.. Mk

aaronic_abacus
2007-03-10, 02:10 AM
Use

(entget(car(entsel)))

at the command prompt to determine the correct DXF codes and formats for your program.

.T.
2007-03-10, 02:23 AM
Hi guys, i tried the latest option and had no success. I'm thinking my computer is getting cranky with me.
anyhow, I've tried the (SETQ TXX (SSGET "X" '((-4 . "<AND")(0 . "TEXT")(50 . 1.5708)(8 . "60 VERT TEXT")(-4 . "AND>"))))

and still that rotation is still getting me. I'm just trying to filter down to the text entities that are on a specific layer and have a specific rotation 90deg... Anyone have a work around. Thanks again, and thanks guys that have help me to this point.. Mk

I think what Tim was saying is to leave the rotation filter out but use the other filters like:

(ssget "X" '((0 . "TEXT")(8 . "60 VERT TEXT")))

then walking through the items in the selection set using something like:

(if (equal (cdr (assoc 50 txt)) 1.5708 0.0001)
(do this stuff......)
)

to test each one. I'm sure he'll straighten me out if that's not it...at least I hope so. :)

miff
2007-03-10, 03:26 AM
Or like so:

(ssget '((0 . "TEXT")
(8 . "60 VERT TEXT")
(-4 . "<AND")
(-4 . ">")
(50 . 1.570795)
(-4 . "<")
(50 . 1.570797)
(-4 . "AND>")))

HTH,
Jeff

.T.
2007-03-10, 03:34 AM
Or like so:

(ssget '((0 . "TEXT")
(8 . "60 VERT TEXT")
(-4 . "<AND")
(-4 . ">")
(50 . 1.570795)
(-4 . "<")
(50 . 1.570797)
(-4 . "AND>")))

HTH,
Jeff

Now why didn't I think of that! Thanks Jeff!

MWKINCAID1
2007-03-10, 08:59 AM
Thanks guys, that worked great. I ran into another problem, that filter worked great and ended up telling me there was other text on that layer that matched those same filters. the additional step i need to tackle is filtering by content. all of the strings of text i want have a = sign in them. i was trying to think up a way to include this in the filter, i haven't gotten it to work yet, i may have to pass the selection set thru another filter?

(VL-STRING-SEARCH (ASCII "=" ) TXC ))

ADDING IT TO THIS. p.s. Thanks to who ever cooked up this slick pi constraint. mk

(setq TXX (ssget "x" (list '(0 . "TEXT")
'(8 . "60 vert text")
(cons 50 (/ pi 2.0)))))

Kerry Brown
2007-03-10, 11:02 AM
Try a wcMatch on "=" :-

(SSGET '((0 . "TEXT")
(8 . "60 VERT TEXT")
(1 . "*=*")
(-4 . "<AND")
(-4 . ">")
(50 . 1.570795)
(-4 . "<")
(50 . 1.570797)
(-4 . "AND>")
)
)
/// kwb

MWKINCAID1
2007-03-10, 11:54 PM
I wanted to share my thanks and my result with you guys, thanks again for all of your help. mk
(setq txx (SSGET "x" '((0 . "TEXT")
(8 . "60 VERT TEXT")
(1 . "*=*")
(-4 . "<AND")
(-4 . ">")
(50 . 1.570795)
(-4 . "<")
(50 . 1.570797)
(-4 . "AND>")
))
)
(setq txx1 (/ (sslength txx) 2))

MWKINCAID1
2007-03-11, 12:43 AM
another question about ssget selection sets.
I want to take the text entities that i have in my selection set and sort them into a list assending by there xvalue. then i want to run them thru the routeen that i made. so far this is what i have.

(defun c:VPT (/ ent)
(setq txx (SSGET "x"
'((0 . "TEXT")
(8 . "60 VERT TEXT")
(1 . "*=*")
(-4 . "<AND")
(-4 . ">")
(50 . 1.570795)
(-4 . "<")
(50 . 1.570797)
(-4 . "AND>")
)
)
)
(setq txx1 (/ (sslength txx) 2))
(REPEAT TXX1
(setq TXA (car (entsel)))
(setq TXB (entget TXA (list "*")))
(setq TXC (cdr (assoc 1 TXB)))
(setq TXC1 (cdr (assoc 11 TXB)))
(SETQ TXC2 (CAR TXC1)) ;XVALUE
(SETQ TXC3 (CADR TXC1)) ;YVALUE
(SETQ TXD (VL-STRING-POSITION (ASCII "+") TXC))
(SETQ TXE (+ TXD 1))
(SETQ TXF (SUBSTR TXC TXE))
(setq TX1 (car (entsel)))
(setq TX2 (entget TX1 (list "*")))
(setq TX3 (cdr (assoc 1 TX2)))
(setq TX31 (cdr (assoc 11 TX2)))
(SETQ TX32 (CAR TX31)) ;XVALUE
(SETQ TX33 (CADR TX31)) ;YVALUE
(SETQ TX4 (VL-STRING-POSITION (ASCII "=") TX3))
(SETQ TX5 (+ TX4 3))
(SETQ TX6 (SUBSTR TX3 TX5))
(SETQ TXG (/ (+ TXC2 TX32) 2)) ;XVALUEMID
(SETQ TX7 (/ (+ TXC3 TX33) 2)) ;YVALUEMID
(SETQ TXH (RTOS TXG))
(SETQ TX8 (RTOS TX7))
(SETQ ELE "Elev ")
(SETQ STA "STA ")
(SETQ PLS "+")
(SETQ EQU "=")
(SETQ PVI " PI")
(setQ CMA ",")
(setq tx1A (car (NentselP (list (distof TXH) (distof TX8)))))
(SETQ TX2A (ENTGET TX1A))
(setq TX3A (cdr (assoc 10 TX2A)))
(setq TX4A (cdr (assoc 11 TX2A)))
(SETQ TX6A (CAR TX3A)) ;XVALUE
(SETQ TX7A (CADR TX3A)) ;YVALUE
(SETQ TX8A (CAR TX4A)) ;XVALUE
(SETQ TX9A (CADR TX4A)) ;YVALUE
(SETQ TX10A (RTOs TX7A))
(SETQ TX11A (RTOs TX9A))
;(IF (< TX10A TX11A) (SETQ 12A TX7A (SETQ TX12A TX9A))
;(setq 14A (list (distof tx8a) (distof tx9a)))
(SETQ LINE1 (STRCAT txf PVI))
(SETQ LINE2 (STRCAT ele tx6))
(COMMAND ".-MTEXT" tx4a "rotation" "90" "justify" "mr" "@" line1 line2 "")
)
(princ)
)[ Moderator Action = ON ] What are [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code) [ Moderator Action = OFF ]

miff
2007-03-13, 02:39 AM
I'm not quite sure what you are trying to do with the code you posted, but this little function will return a list of the selection set's entities' elist, all sorted by X.

(defun sortSSbyX (ss / ent elist objlist)
(while (setq ent (ssname ss 0))
(setq elist (entget ent))
(setq objlist (cons elist objlist))
(ssdel ent ss)
)
(vl-sort objlist '(lambda (x1 x2)
(< (cadr (assoc 10 x1)) (cadr (assoc 10 x2)))
)
)
)

HTH,
Jeff

MWKINCAID1
2007-03-13, 09:51 PM
maybe i'm just tired, or inexperienced. but i haven't figured out how to incorperate the while statement "shown below" into this bit of code.

(setq txx (SSGET "x"
'((0 . "TEXT")
(8 . "60 VERT TEXT")
(1 . "*ELEV*")
(-4 . "<AND")
(-4 . ">")
(50 . 1.570795)
(-4 . "<")
(50 . 1.570797)
(-4 . "AND>")
)
)
)(defun sortSSbyX (ss / ent elist objlist)
(while (setq ent (ssname ss 0))
(setq elist (entget ent))
(setq objlist (cons elist objlist))
(ssdel ent ss)
)
(vl-sort objlist '(lambda (x1 x2)
(< (cadr (assoc 10 x1)) (cadr (assoc 10 x2)))
)
)
)[ Moderator Action = ON ] What are [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code) [ Moderator Action = OFF ]

.T.
2007-03-13, 10:01 PM
maybe i'm just tired, or inexperienced. but i haven't figured out how to incorperate this into this bit of code.

(setq txx (SSGET "x"
'((0 . "TEXT")
(8 . "60 VERT TEXT")
(1 . "*ELEV*")
(-4 . "<AND")
(-4 . ">")
(50 . 1.570795)
(-4 . "<")
(50 . 1.570797)
(-4 . "AND>")
)
)
)


Once you have the selection set stored in the txx variable, just pass that variable to the sortSSbyX function like:

(setq txx2 (sortSSbyX txx))

HTH

PS: you might want to wrap the code you post in code tags. just select the code and push the # (pound sign) button.

HTH

MWKINCAID1
2007-03-14, 10:05 PM
Okay guys, this is what i have so far, the only problem is that it doesn't run. i've tested the items individually and in order of setting, and all the pieces work, i just can't find the bust. p.s. any tips or comments on how i could have done this better are always appreciated.. thanks, mk
(defun c:VPT ()

(setq txx1 (SSGET "x" '((0 . "TEXT")
(8 . "60 VERT TEXT")
(1 . "*STA =*")
(-4 . "<AND")
(-4 . ">")
(50 . 1.570795)
(-4 . "<")
(50 . 1.570797)
(-4 . "AND>")
)
)
)
(defun sortSSbyX (ss / ent elist objlist)
(while (setq ent (ssname ss 0))
(setq elist (entget ent))
(setq objlist (cons elist objlist))
(ssdel ent ss)
)
(vl-sort objlist '(lambda (x1 x2)
(< (cadr (assoc 10 x1)) (cadr (assoc 10 x2)))
)
)
)
(setq txx2 (sortSSbyX txx1))
(SETQ TXX3 (SSGET "P" ))
(setq txx4 (SSGET "x" '((0 . "TEXT")
(8 . "60 VERT TEXT")
(1 . "*ELEV =*")
(-4 . "<AND")
(-4 . ">")
(50 . 1.570795)
(-4 . "<")
(50 . 1.570797)
(-4 . "AND>")
)
)
)
(setq txx5 (sortSSbyX txx4))
(SETQ TXX6 (SSGET "P" ))
(SETQ ELE "Elev ")
(SETQ STA "STA ")
(SETQ PLS "+")
(SETQ EQU "=")
(SETQ PVI " PI")
(setQ CMA ",")
(setq tmer1 0)
(REPEAT (SSLENGTH TXX3)
(setq tmer1 tmer)
(setq TXB (entget (SSNAME TXX3 tmer1)))
(setq TXC (cdr (assoc 1 TXB)))
(setq TXC1 (cdr (assoc 11 TXB)))
(SETQ TXC2 (CAR TXC1));XVALUE
(SETQ TXC3 (CADR TXC1));YVALUE
(SETQ TXD (VL-STRING-POSITION (ASCII "+" ) TXC ))
(SETQ TXE (+ TXD 2))
(SETQ TXF (SUBSTR TXC TXE ))
(setq TX2 (entget (ssname txx6 tmer1)))
(setq TX3 (cdr (assoc 1 TX2)))
(setq TX31 (cdr (assoc 11 TX2)))
(SETQ TX32 (CAR TX31));XVALUE
(SETQ TX33 (CADR TX31));YVALUE
(SETQ TX4 (VL-STRING-POSITION (ASCII "=" ) TX3 ))
(SETQ TX5 (+ TX4 3))
(SETQ TX6 (SUBSTR TX3 TX5 ))
(SETQ TXG (/ (+ TX32 TXc2) 2));xVALUEMID
(SETQ TX7 (/ (+ TXC3 TX33) 2));YVALUEMID
(SETQ TXH (RTOS TXG))
(SETQ TX8 (RTOS TX7))
(setq tx1A (car (NentselP (list (distof TXH) (distof TX8)))))
(SETQ TX2A (ENTGET TX1A))
(setq TX3A (cdr (assoc 10 TX2A)))
(setq TX4A (cdr (assoc 11 TX2A)))
(SETQ TX6A (CAR TX3A));XVALUE
(SETQ TX7A (CADR TX3A));YVALUE
(SETQ TX8A (CAR TX4A));XVALUE
(SETQ TX9A (CADR TX4A));YVALUE
(SETQ TX10A (RTOs TX7A))
(SETQ TX11A (RTOs TX9A))
(SETQ TX13A (RTOS TX6A))
(IF (< TX11A TX10A) (SETQ tx12A TX10A) (SETQ TX12A TX11A));yvalueofplacedmtext
(setq TX14A (list (distof tx13A) (distof tx12a)))
(SETQ LINE1 (STRCAT txf PVI))
(SETQ LINE2 (STRCAT ele tx6 ))
(COMMAND ".-MTEXT" tx14a "rotation""90" "justify""mr" "@" line1 line2"")
(setq tmer (+ 1 tmer1)))
(princ)
)

miff
2007-03-14, 11:28 PM
I'm still unable to follow exactly what you are trying to accomplish, mk. I think you are selecting all the 90deg text in a profile, sorting the station & Fg labels, and recreating the Text with MText that has a MiddleRight justification. Is that close?

One reason for the code being difficult to decipher is your use of nearly identical variable names. Try using variables with names that somewhat match what they are gong to be representing. Seeing TX11, TX1, TX10 is just confusing.

Next, the sort routine I gave you eliminates the need for additional selection sets (the (ssget "P")'s). Just use the list that is returned with all of the data you require.

Also, what is the purpose of the (nentselp)? It seems to me you already have the entity....like I said, it's hard to follow what you are wanting to do.

If you could post a sample drawing of what you have and what you'd like to end up with, I could probably help you finish this rather quickly.

Jeff

MWKINCAID1
2007-03-15, 04:34 AM
Hey Jeff, thanks again for all of your help, I've re-typed up the code and tried to use more explitive variables. i'lll also go ahead and attach a before and after product. I tried to make this as detailed as possible.
(defun c:VPT (/ ent)

;;ROUTEEN TO SORT THE SELECTION SETS BY THE XVALUE
(defun sortSSbyX (ss / ent elist objlist)
(while (setq ent (ssname ss 0))
(setq elist (entget ent))
(setq objlist (cons elist objlist))
(ssdel ent ss)
)
(vl-sort objlist '(lambda (x1 x2)
(< (cadr (assoc 10 x1)) (cadr (assoc 10 x2)))
)
)
)
;;SOME GENERIC VARABLES I MAY NEED LATER FOR FORMATTING
(SETQ ELE "Elev ")
(SETQ STA "STA ")
(SETQ PLS "+")
(SETQ EQU "=")
(SETQ PVI " PI")
(setQ CMA ",")


;;STATION SELECTOIN SET
(setq STASET (SSGET "x" '((0 . "TEXT")
(8 . "60 VERT TEXT")
(1 . "*STA =*")
(-4 . "<AND")
(-4 . ">")
(50 . 1.570795)
(-4 . "<")
(50 . 1.570797)
(-4 . "AND>")
)
)
)
;;RUNS THE SELECTION SET THRU THE SORTER
(setq STASET1 (sortSSbyX STASET))
;;CREATES A SELECTION SET OF JUST THE ENTITY NAMES FROM THE SORTED SELECTION SET
(SETQ STASET2 (SSGET "P" ))

;;ELEVATION SELECTION SET
(setq ELEVSET (SSGET "x" '((0 . "TEXT")
(8 . "60 VERT TEXT")
(1 . "*ELEV =*")
(-4 . "<AND")
(-4 . ">")
(50 . 1.570795)
(-4 . "<")
(50 . 1.570797)
(-4 . "AND>")
)
)
)
;;RUNS THE SELECTION SET THRU THE SORTER
(setq ELEVSET1 (sortSSbyX ELEVSET))

;;CREATES A SELECTION SET OF JUST THE ENTITY NAMES FROM THE SORTED SELECTION SET
(SETQ ELEVSET2 (SSGET "P" ))

;;THIS IS MY COUNTER TO INCREMENT THE INDEX NUMBER WITH EVERY RUN THRU THE LOOP
(SETQ TIMERA 0)

;;SETS THE LOOP RUNS BY THE NUMBER OF ENTITIES IN THE SELECTION SET
(REPEAT (- (SSLENGTH STASET2) 1 )

;THIS FEEDS AND COUNTS UP FOR EVERY RUN THRU
(SETQ TIMERA TIMERB)<<<I THINK THERE IS A CONFLICT HERE

;;SELECTS THE FIRST ELEMENT IN THE STATION SELECTION SET
(setq STAINFO (entget (SSNAME STASET2 TIMERA)))

;;THIS PULLS THE STRING INFORMATION OUT OF THE TEXT
(setq STRNSTA (cdr (assoc 1 STAINFO)))

;;THIS PULLS OUT THE X, Y, AND Z VALUE OF THE TEXT PLACEMENT
(setq STAXYZ (cdr (assoc 11 STAINFO)))

;;THIS PULLS OUT THE X VALUE
(SETQ STAX (CAR STAXYZ))

;;THIS PULLS OUT THE Y VALUE
(SETQ STAY (CADR STAXYZ))

;;THIS FINDS THE + NEEDED FOR THE STRING EXTRACTION OF THE NUMBER
(SETQ STAPLS (VL-STRING-POSITION (ASCII "+" ) STRNSTA ))

;;THIS ADDS 2 SPACES TO THE SUBSTR FOR THE BEGINING OF THE STRING I WANT
(SETQ STASTRT (+ STAPLS 2))

;;THIS STRIPS OUT THE NUMBER I WANT FROM THE STRING
(SETQ STADTA (SUBSTR STRNSTA STASTRT ))

;;THIS REPEATS THE SAME PROCESS FOR THE ELEVATION SELECTION SET
(setq ELEVINFO (entget (SSNAME ELEVSET2 TIMERA)))

;;THIS PULLS THE STRING INFORMATION OUT OF THE TEXT
(setq ELEVSTRN (cdr (assoc 1 ELEVINFO)))

;;THIS PULLS OUT THE XYZ FROM THE TEXT STRING
(setq ELEVXYZ (cdr (assoc 11 ELEVINFO)))

;;tHIS PULLS OUT THE X VALUE
(SETQ ELEVX (CAR ELEVXYZ))

;;tHIS PULLS OUT THE Y VALUE
(SETQ ELEVY (CADR ELEVXYZ))

;;tHIS FINDS THE = NEEDED FOR THE STRING EXTRACTION OF THE NUMBER
(SETQ ELEVEQL (VL-STRING-POSITION (ASCII "=" ) ELEVSTRN ))

;;THIS ADDS 3 SPACES TO THE SUBSTR FO THE BEGINING OF THE STRING I WANT
(SETQ ELEVSTRT (+ ELEVEQL 3))

;;THIS STRIPS OUT THE NUMBER I WANT FROM THE STRING
(SETQ ELEVNFO (SUBSTR ELEVSTRN ELEVSTRT ))

;;THIS FINDS THE MIDPOINT BETWEEN THE 2 XVALUES
(SETQ PICX (/ (+ STAX ELEVX) 2))

;;THIS FINDS THE MIDPOINT BETWEEN THE 2 Y VALUES
(SETQ PICY (/ (+ STAY ELEVY) 2))

;;THIS CONVERTS THE X AND Y NUMBER INTO STRINGS
(SETQ PICX1 (RTOS PICX))
(SETQ PICY1 (RTOS PICY))

;;THIS SELECTS THE LINE GIVEN THE X,Y POINT WE DETERMINDED ABOVE INBETWEEN THE 2 STRINGS OF TEXT THAT WE'LL USE TO PLACE THE MTEXT BOX AND OUR NEWLY FORMATTED TEXT
(setq LNPNT (car (NentselP (list (DISTOF PICX1) (DISTOF PICY1)))))

;;THIS GETS THE INFORMATION FROM THE LINE
(SETQ LINE (ENTGET LNPNT))

;;THIS PULLES THE X AND Y FROM ONE END OF THE LINE
(setq PNTA (cdr (assoc 10 LINE)))

;;THIS PULLES THE X AND Y FROM THE OTHER END OF THE LINE
(setq PNTB (cdr (assoc 11 LINE)))

;;THIS PULLS THE X FROM PNTA
(SETQ PNTAX (CAR PNTA))

;;THIS PULLS THE Y FROM PNTA
(SETQ PNTAY (CADR PNTA))

;;THIS PULLS THE X FROM PNTB
(SETQ PNTBX (CAR PNTB))

;;THIS PULLS THE Y FROM PNTB
(SETQ PNTBY (CADR PNTB))

;;THIS DECIDES WHICH Y VALUE IS GREATER AND CHOOSES IT
(IF (> PNTAY PNTBY) (SETQ TXTPNTY PNTAY) (SETQ TXTPNTY PNTBY))

;;THIS SETS THE X AND Y POINTS TO STRINGS
(SETQ MTXTPTX (RTOS PNTBX))
(SETQ MTXTPTY (RTOS TXTPNTY))

;;THIS SETS AND COMBINES THE CALCULATED X AND Y PLACEMENT FOR THE MTEXT STRING
(setq MTXTPNT (list (distof MTXTPTX) (distof MTXTPTY)))

;;THIS ASSEMBLES THE VARIABLES INTO THE COMPANIES ORDER
(SETQ LINE1 (STRCAT STADTA PVI))
(SETQ LINE2 (STRCAT ELE ELEVNFO PVI ))
;;THIS PLACES THE MTEXT BOX AT THE END OF THE LINE AND FILLES IT WITH THE CORRECT FORMATT
(COMMAND ".-MTEXT" MTXTPNT "rotation""90" "justify""mr" "@" line1 line2"")
)
(SETQ TIMERB (+ TIMERA 1)
)
;;END OF REPEAT
;;RESETS TIMER VARIABLE FOR THE LOOP INCASE NEEDED TO RE-RUN COMMAND.
(SETQ TIMERA 0)
(SETQ TIMERB 0)
(princ)
)

miff
2007-03-15, 07:43 PM
You're welcome. I've made some revisons and the code now works as I think you intended. I've added a few comments (probably not enough) so hopefully you can see what I did. The biggest thing is that there is no use for Previous selections sets.....they just are duplicates of the original, unsorted, SS's. That's why I had the sort function return a list of the data you need. I also remove the (nentselp) and replaced it with a filtered selection set using the Fence option between the 2 text inserts. This insures the line you want is selected.....it would pickup ANY Acad entity , depending on your zoom level, before.

Note that the code of yours I no longer use I just commented out, instead of deleting it, so you can better see what I did. There are other things I would have done differently, but they are more personal preference than anything else.

I hope this helps you get to your end result.

Jeff

(defun c:VPT (/ ent cma ele eleveql elevinfo
elevnfo elevset elevset1 elevset2 elevstrn elevstrt
elevx elevxyz elevy equ line line1
line2 lnpnt mtxtpnt mtxtptx mtxtpty picx
picx1 picy picy1 pls pnta pntax
pntay pntb pntbx pntby pvi sta
stadta stainfo stapls staset staset1 stastrt
stax staxyz stay strnsta timera txtpnty
lineset
)

;;ROUTINE TO SORT THE SELECTION SETS BY THE XVALUE
(defun sortSSbyX (ss / ent elist objlist)
(while (setq ent (ssname ss 0))
(setq elist (entget ent))
(setq objlist (cons elist objlist))
(ssdel ent ss)
)
(vl-sort objlist
'(lambda (x1 x2)
(< (cadr (assoc 10 x1)) (cadr (assoc 10 x2)))
)
)
)
;;SOME GENERIC VARABLES I MAY NEED LATER FOR FORMATTING
(SETQ ELE "Elev ")
(SETQ STA "STA ")
(SETQ PLS "+")
(SETQ EQU "=")
(SETQ PVI " PI")
(setQ CMA ",")


;;STATION SELECTION SET
(setq STASET (SSGET "x"
'((0 . "TEXT")
(8 . "60 VERT TEXT")
(1 . "*STA =*")
(-4 . "<AND")
(-4 . ">")
(50 . 1.570795)
(-4 . "<")
(50 . 1.570797)
(-4 . "AND>")
)
)
)
;;RUNS THE SELECTION SET THRU THE SORTER
(setq STASET1 (sortSSbyX STASET))
;;CREATES A SELECTION SET OF JUST THE ENTITY NAMES FROM THE SORTED SELECTION SET
;;(SETQ STASET2 (SSGET "P")) ;;;;not used

;;ELEVATION SELECTION SET
(setq ELEVSET (SSGET "x"
'((0 . "TEXT")
(8 . "60 VERT TEXT")
(1 . "*ELEV =*")
(-4 . "<AND")
(-4 . ">")
(50 . 1.570795)
(-4 . "<")
(50 . 1.570797)
(-4 . "AND>")
)
)
)
;;RUNS THE SELECTION SET THRU THE SORTER
(setq ELEVSET1 (sortSSbyX ELEVSET))

;;CREATES A SELECTION SET OF JUST THE ENTITY NAMES FROM THE SORTED SELECTION SET
;;(SETQ ELEVSET2 (SSGET "P"));;; not used
;;;;; added a (mapcar) and removed the Repeat
(mapcar '(lambda (stainfo elevinfo)
;;(setq STAINFO (entget (SSNAME STASET2 TIMERA)))

;;THIS PULLS THE STRING INFORMATION OUT OF THE TEXT
(setq STRNSTA (cdr (assoc 1 STAINFO)))

;;THIS PULLS OUT THE X, Y, AND Z VALUE OF THE TEXT PLACEMENT
(setq STAXYZ (cdr (assoc 11 STAINFO)))

;;; ;;THIS PULLS OUT THE X VALUE
;;; (SETQ STAX (CAR STAXYZ))
;;;
;;; ;;THIS PULLS OUT THE Y VALUE
;;; (SETQ STAY (CADR STAXYZ))
;;;
;;THIS FINDS THE + NEEDED FOR THE STRING EXTRACTION OF THE NUMBER
(SETQ STAPLS (VL-STRING-POSITION (ASCII "+") STRNSTA))

;;THIS ADDS 2 SPACES TO THE SUBSTR FOR THE BEGINING OF THE STRING I WANT
(SETQ STASTRT (+ STAPLS 2))

;;THIS STRIPS OUT THE NUMBER I WANT FROM THE STRING
(SETQ STADTA (SUBSTR STRNSTA STASTRT))

;;THIS REPEATS THE SAME PROCESS FOR THE ELEVATION SELECTION SET
;;(setq ELEVINFO (entget (SSNAME ELEVSET2 TIMERA)))

;;THIS PULLS THE STRING INFORMATION OUT OF THE TEXT
(setq ELEVSTRN (cdr (assoc 1 ELEVINFO)))

;;THIS PULLS OUT THE XYZ FROM THE TEXT STRING
(setq ELEVXYZ (cdr (assoc 11 ELEVINFO)))

;;; ;;tHIS PULLS OUT THE X VALUE
;;; (SETQ ELEVX (CAR ELEVXYZ))
;;;
;;; ;;tHIS PULLS OUT THE Y VALUE
;;; (SETQ ELEVY (CADR ELEVXYZ))
;;;
;;tHIS FINDS THE = NEEDED FOR THE STRING EXTRACTION OF THE NUMBER
(SETQ ELEVEQL (VL-STRING-POSITION (ASCII "=") ELEVSTRN))

;;THIS ADDS 3 SPACES TO THE SUBSTR FO THE BEGINING OF THE STRING I WANT
(SETQ ELEVSTRT (+ ELEVEQL 3))

;;THIS STRIPS OUT THE NUMBER I WANT FROM THE STRING
(SETQ ELEVNFO (SUBSTR ELEVSTRN ELEVSTRT))

;;; ;;THIS FINDS THE MIDPOINT BETWEEN THE 2 XVALUES
;;; (SETQ PICX (/ (+ STAX ELEVX) 2))
;;;
;;; ;;THIS FINDS THE MIDPOINT BETWEEN THE 2 Y VALUES
;;; (SETQ PICY (/ (+ STAY ELEVY) 2))
;;;
;;; ;;THIS CONVERTS THE X AND Y NUMBER INTO STRINGS
;;; (SETQ PICX1 (RTOS PICX))
;;; (SETQ PICY1 (RTOS PICY))

;;THIS SELECTS THE LINE GIVEN THE X,Y POINT WE DETERMINDED ABOVE INBETWEEN THE 2 STRINGS OF TEXT THAT WE'LL USE TO PLACE THE MTEXT BOX AND OUR NEWLY FORMATTED TEXT
;;; (setq
;;; LNPNT (car (NentselP (list (DISTOF PICX1) (DISTOF PICY1))))
;;; )
;;getsthe Line between the 2 in a Selection Set
(setq LINESET (SSGET "f" (list staxyz elevxyz)
'((0 . "LINE")
(8 . "60 VERT TEXT")
)
)
)


;;THIS GETS THE INFORMATION FROM THE LINE
(SETQ LINE (ENTGET (ssname lineset 0)))

;;THIS PULLES THE X AND Y FROM ONE END OF THE LINE
(setq PNTA (cdr (assoc 10 LINE)))

;;THIS PULLES THE X AND Y FROM THE OTHER END OF THE LINE
(setq PNTB (cdr (assoc 11 LINE)))

;;THIS PULLS THE X FROM PNTA
(SETQ PNTAX (CAR PNTA))

;;THIS PULLS THE Y FROM PNTA
(SETQ PNTAY (CADR PNTA))

;;THIS PULLS THE X FROM PNTB
(SETQ PNTBX (CAR PNTB))

;;THIS PULLS THE Y FROM PNTB
(SETQ PNTBY (CADR PNTB))

;;THIS DECIDES WHICH Y VALUE IS GREATER AND CHOOSES IT
(IF (> PNTAY PNTBY)
(SETQ TXTPNTY PNTAY)
(SETQ TXTPNTY PNTBY)
)

;;THIS SETS THE X AND Y POINTS TO STRINGS
(SETQ MTXTPTX (RTOS PNTBX))
(SETQ MTXTPTY (RTOS TXTPNTY))

;;THIS SETS AND COMBINES THE CALCULATED X AND Y PLACEMENT FOR THE MTEXT STRING
(setq MTXTPNT (list (distof MTXTPTX) (distof MTXTPTY)))

;;THIS ASSEMBLES THE VARIABLES INTO THE COMPANIES ORDER
(SETQ LINE1 (STRCAT STADTA PVI))
(SETQ LINE2 (STRCAT ELE ELEVNFO PVI))
;;THIS PLACES THE MTEXT BOX AT THE END OF THE LINE AND FILLES IT WITH THE CORRECT FORMATT
(COMMAND ".-MTEXT" MTXTPNT "rotation" "90"
"justify" "mr" "@" line1 line2
""
)
)
staset1
elevset1
;;(SETQ TIMERB (+ TIMERA 1)
)
;;END OF REPEAT
;;RESETS TIMER VARIABLE FOR THE LOOP INCASE NEEDED TO RE-RUN COMMAND.
;;; (SETQ TIMERA 0)
;;; (SETQ TIMERB 0)
(princ)
)

miff
2007-03-15, 08:07 PM
Oh, there's a few other issues that should/need to be addressed.

1.Getting a selection by any method other than "X" requires the objects to be visible on screen, so a zoom extents should be added.

2. Object snaps should be turned off prior to anything else and restored at the end, else Fence selection (I don't recall if running Osnaps are honored with the Fence option) and the Mtext creation may be adversely affected.

MWKINCAID1
2007-03-15, 08:12 PM
!!!AWESOME!!!! That works exactly how i wanted it. Thank you so much for all of your help and time. Thanks jeff. mk