Author Topic: Pulling information from a Field  (Read 14384 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Pulling information from a Field
« Reply #30 on: July 13, 2006, 05:40:51 PM »
Well it may be easier to modify the mtext to make the sheet number reliable.
Your choices are as you listed in you first post as well as plain text.
The problem with mtext as you have discovered is the use of formatting characters.
What ever you choose is up to you & how your drafters will adapt to the change.
As for the amount of code, that is a small price to pay for getting the job done
in a timely manner. SO I don't see the volume of code being the criterion for
consideration of which method to use. I would be more concerned with the impact
on the staff & production both short & long term.

My 2 cents. :-)
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.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Pulling information from a Field
« Reply #31 on: July 14, 2006, 07:55:14 AM »
Well it may be easier to modify the mtext to make the sheet number reliable.
Your choices are as you listed in you first post as well as plain text.
The problem with mtext as you have discovered is the use of formatting characters.
What ever you choose is up to you & how your drafters will adapt to the change.
As for the amount of code, that is a small price to pay for getting the job done
in a timely manner. SO I don't see the volume of code being the criterion for
consideration of which method to use. I would be more concerned with the impact
on the staff & production both short & long term.

My 2 cents. :-)

Thanks for your 2 Cents Cab.  :-)
I really do appreciate people’s opinions and takes on things and I make a habit of listening.  Never know what you can learn.

I had to drive to up to a race just to get a taste of defeat.  So on the way back I did some thinking about this routine.  I came to same thing as you have listed.  My realization is the whole human factor, you can count on it to throw you a curve ball.  My users (half of them being Architect Interns) will have their opinions on how an item should look like.  So therefore they are going to tweak the Mtext for either legitimate reasons or not.  So it is better to have a code to anticipate that. 

Thanks
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Pulling information from a Field
« Reply #32 on: July 14, 2006, 08:22:12 AM »
If it were me I would most likely use a block with attributes for the  Drawing number, title and scale.
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.

Sdoman

  • Guest
Re: Pulling information from a Field
« Reply #33 on: July 14, 2006, 08:36:30 AM »

 Would using an attribute be easier? 


Much easier imo.  Using an attribute, you can easily extract the sheet number data and not have to deal with mtext formatting. Even easier is using an attribute that displays the layout name. 

Either of the expressions below should work for displaying the layout name, depending on your AutoCAD version.  The first expression below is what I've been using since 2005, the second expression wasn't available at that time.

%<\AcDiesel $(getvar,ctab)>%
 - or -
%<\AcVar ctab>%

Now name the layout tabs to whatever you want your sheets to be named.  The sheet number attribute will update automagically.  When you plot to file, AutoCAD will append the layout name to the drawing name and use that for the plot file name.  You can accept that plot file name, or manually or programmatically use another name.


Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Pulling information from a Field
« Reply #34 on: July 14, 2006, 09:34:01 AM »
If it were me I would most likely use a block with attributes for the  Drawing number, title and scale.

We just went through a major change to xref the titile block to quell the whining of clunkieness of the previous Title Block that was extremly bloated with attruibutes and I agree with them.  The think I like about using mtext vs attrubites is the mtext you can have multilple lines of text in one enity.  An it is something familiar to my users.

Steved

If I understand you correctly, are you having the layout tab copy the drawing number and the user edits the drawing number? Or is it the other way around?
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Pulling information from a Field
« Reply #35 on: July 14, 2006, 09:38:25 AM »
I am getting this at the command line
Quote
Command: 'VLIDE
Command:
Command: dwg .undo Current settings: Auto = On, Control = All, Combine = Yes
Enter the number of operations to undo or [Auto/Control/BEgin/End/Mark/Back]
<1>: m
Command:
Command:
Command:
Command: too few arguments
Command: 'VLIDE

and getting this in the watch window
Quote
LOG Watch
...............
DWG# = nil
SS = <Selection set: 26>
TXT = "{\\T0.9;A1.02}"

Code Attached
Code: [Select]
(defun c:dwg ()
  (vl-cmdf ".undo" "m")

;;;=======================[ Strip_Text.lsp ]=============================
;;; Author:  Charles Alan Butler Copyright© 2005
;;; Version: 2.2  Oct. 19, 2005
;;; Purpose: Strip format characters from text or mtext
;;; Returns: A string 
;;; Sub_Routines: -None
;;; Arguments: A string variable
;;;======================================================================

(defun strip_text (str / skipcnt ndx newlst char fmtcode lst_len
                   IS_MTEXT LST  NEXTCHR PT TMP)

  (setq ndx 0
        ;; "fmtcode" is a list of code flags that will end with ;
        fmtcode
         (vl-string->list "CcFfHhTtQqWwAa") ;("\C" "\F" "\H" "\T" "\Q" "\W" "\A")
  )
  (if (/= str "") ; skip if empty text ""
    (progn
      (setq lst      (vl-string->list str)
            lst_len  (length lst)
            newlst   '()
            is_mtext nil ; true if mtext
      )
      (while (< ndx lst_len)
        ;; step through text and find FORMAT CHARACTERS
        (setq char    (nth ndx lst) ; Get next character
              nextchr (nth (1+ ndx) lst)
              skipcnt 0
        )

        (cond
          ((and (= char 123) (= nextchr 92)) ; "{\" mtext code
           (setq is_mtext t
                 skipcnt 1
           )
          )

          ((and (= char 125) is_mtext) ; "}"
           (setq skipcnt 1)
          )


          ((= char 37) ; code start with "%"
           (if (null nextchr) ; true if % is last char in text
             (setq skipcnt 1)
             ;;  Dtext codes
             (if (= nextchr 37) ; %% code found
               (if (< 47 (nth (+ ndx 2) lst) 58) ; is a number
                 ;;number found so fmtcode %%nnn
                 (setq skipcnt 6)
                 ;; else letter code, so fmtcode %%p
                 (setq skipcnt 4)
               ) ; endif
             ) ; endif
           ) ; endif
          ) ; end cond (= char "%"))


          ((= char 92) ; code start with "\"
           ;;  This section processes mtext codes

           (cond
             ;; Process Coded information
             ((null nextchr) ; true if \ is last char in text
              (setq skipcnt 1)
             ) ; end cond 1

             ((member nextchr fmtcode) ; this code will end with ";"
              ;; fmtcode -> ("\C" "\F" "\H" "\T" "\Q" "\W" "\A"))
              (while (/= (setq char (nth (+ skipcnt ndx) lst)) 59)
                (setq skipcnt (1+ skipcnt))
              )
              (setq skipcnt (1+ skipcnt))
             ) ; end cond


             ;; found \U then get 7 character group
             ((= nextchr 85) (setq skipcnt (+ skipcnt 8)))

             ;; found \M then get 8 character group
             ((= nextchr 77) (setq skipcnt (+ skipcnt 9)))

             ;; found \P then replace with CR LF 13 10
             ;;  debug do not add CR LF, just remobe \P
             ((= nextchr 80) ; "\P"
              (setq newlst  (append newlst '(32))
                    ;ndx     (+ ndx 1)
                    skipcnt 2
              )
             ) ; end cond


             ((= nextchr 123) ; "\{" normal brace
              (setq ndx (+ ndx 1))
             ) ; end cond

             ((= nextchr 125) ; "\}" normal brace
              (setq ndx (+ ndx 1))
             ) ; end cond

             ((= nextchr 126) ; "\~" non breaking space
              (setq newlst (append newlst '(32))) ; " "
              (setq skipcnt 2) ; end cond 9
             )

             ;; 2 character group \L \l \O \o
            ((member nextchr '(76 108 79 111))
              (setq skipcnt 2)
             ) ; end cond

             ;;  Stacked text format as "[ top_txt / bot_txt ]"
             ((= nextchr 83) ; "\S"
              (setq pt  (1+ ndx)
                    tmp '()
              )
              (while
                (not
                  (member
                    (setq tmp (nth (setq pt (1+ pt)) lst))
                    '(94 47 35) ; "^" "/" "#" seperator
                  )
                )
                 (setq newlst (append newlst (list tmp)))
              )
              (setq newlst (append newlst '(47))) ; "/"
              (while (/= (setq tmp (nth (setq pt (1+ pt)) lst)) 59) ; ";"
                (setq newlst (append newlst (list tmp)))
              )
              (setq ndx     pt
                    skipcnt (1+ skipcnt)
              )
             ) ; end cond


           ) ; end cond stmt  Process Coded information
          ) ; end cond  (or (= char "\\")

        ) ; end cond stmt
        ;;  Skip format code characters
        (if (zerop skipcnt) ; add char to string
          (setq newlst (append newlst (list char))
                ndx    (+ ndx 1)
          )
          ;;  else skip some characters
          (setq ndx (+ ndx skipcnt))
        )

      ) ; end while Loop
    ) ; end progn
  ) ; endif
  (vl-list->string newlst) ; return the stripped string
) ; end defun
;;;======================================================================

  (setq ss
(ssget "_x"
(list
  (cons 410 (getvar "ctab"))
  (cons 0 "MTEXT")
  (cons 7 "helv-meds-19")
  (CONS 8 "TITLE-BLOCK-TEXT")
)
)
  )
  (setq txt (cdr (assoc 1 (entget (ssname SS 0)))))
  (setq txt (strip_text));;Mtext Formating Code Stripper
)
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Sdoman

  • Guest
Re: Pulling information from a Field
« Reply #36 on: July 14, 2006, 10:00:46 AM »

Steved

If I understand you correctly, are you having the layout tab copy the drawing number and the user edits the drawing number? Or is it the other way around?

The title block drawing contains an attribute with field as I described earlier.  We never edit this attribute.  We edit the layout tab name to be the sheet number. The titleblock can be Xref'd or not, works either way.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Pulling information from a Field
« Reply #37 on: July 14, 2006, 10:16:02 AM »
I am getting this at the command line

and getting this in the watch window

Code Attached

Never mind figured it out.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Pulling information from a Field
« Reply #38 on: July 14, 2006, 11:22:58 AM »
Now it my principals that are screwing me over  :x :x :x

I thought we had it.

Code: [Select]
(cons 7 "helv-meds-19" "helv14")
I need search data for EITHER "helv-meds-19" OR "helv14".  Can this be done?  Please point me in the right direction.

My glorious principles and them having each their own titleblock have rolled me again.   :realmad: :realmad:  They cant agree on a common title block. arrggg  And they have to have separate text styles.  This has been going since the 5 years that I have been here.

I tried something similar to this "Filtering for Extended Data" section of Help.  Was getting too many arguments or bad arguments.
Quote
(ssget "X" '((0 . "CIRCLE") (-3 ("APP1,APP2"))))
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Pulling information from a Field
« Reply #39 on: July 14, 2006, 12:18:00 PM »
I need search data for EITHER "helv-meds-19" OR "helv14".  Can this be done?  Please point me in the right direction.

Yes.  I think you would need to have it look like
Code: [Select]
(setq ss
 (ssget
  '(
   (0 . "MTEXT")
   (-4 . "<OR")
    (7 . "helv-meds-19")
    (7 . "helv14")
   (-4 . "OR>")
  )
 )
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Pulling information from a Field
« Reply #40 on: July 14, 2006, 01:35:12 PM »
What is the difference between the dots "." and the "cons"?
Where would I use one over the other?
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Pulling information from a Field
« Reply #41 on: July 14, 2006, 02:01:09 PM »
What is the difference between the dots "." and the "cons"?
Where would I use one over the other?
The use of cons in generally used when you are making an associated list [ (0 . 0) ] and have a variable.  So
(0 . "MTEXT")
is the same as
(cons 0 "MTEXT")

Hope that makes sense.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Pulling information from a Field
« Reply #42 on: July 14, 2006, 02:40:51 PM »
Why not?
Code: [Select]
(cons 7 "helv-meds-19,helv14")
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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Pulling information from a Field
« Reply #43 on: July 14, 2006, 02:54:45 PM »
(quote exp)  Returns an expression without evaluating it.
_$ (quote (8 . "0"))
(8 . "0")

And a single quotation mark is the shorthand for quote.
_$ ' (8 . "0")
(8 . "0")

Where as (cons itm1 itm2)  constructs a dotted list when itm2 is an atom.
_$ (cons 8  "0")
(8 . "0")


If itm1 or itm2 is a variable you need to use cons because the variable needs to be evaluated.
_$ (setq var "abc")
"abc"
_$ (cons 8 var)
(8 . "abc")
_$ (quote (8 . var))
(8 . VAR)
_$ '(8 . var)
(8 . VAR)
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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Pulling information from a Field
« Reply #44 on: July 14, 2006, 03:05:53 PM »
Why not?
Code: [Select]
(cons 7 "helv-meds-19,helv14")
I thought about that, but then I thought it wouldn't work for some strange reason.  It has been a weird day at work for me.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.