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

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Pulling information from a Field
« Reply #15 on: July 13, 2006, 12:13:54 PM »
I have steel toed construction boots.  :lmao:

And appreciate all the help I can get. 8-)
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 #16 on: July 13, 2006, 12:27:48 PM »
I have steel toed construction boots.  :lmao:

And appreciate all the help I can get. 8-)

I need all the help I can get too.  But when you say it Cab, one could think that you you need a help in teaching me because I am so slow.   :lmao:
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 #17 on: July 13, 2006, 12:31:44 PM »
Maybe posting a filled out title block would be best, then we can see what would be the best way to search for your information.
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 #18 on: July 13, 2006, 12:44:20 PM »
I need all the help I can get too.  But when you say it Cab, one could think that you you need a help in teaching me because I am so slow.   :lmao:

I hope no one took it that way :-)

Try listing out all the sheet label options:
A1 - A99
S1 - S99
TP
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 #19 on: July 13, 2006, 12:48:47 PM »
Maybe posting a filled out title block would be best, then we can see what would be the best way to search for your information.

Actually I just found it .  The Text Style.  The Drawing number has a unique text.  Ah I am going to say is my fearless leader created the title block.  Normally he creates more work but this time he inadvertly help me (us).  If I confine the search to just paper space and the text style I should come with the just the data for the drawing number.
see code. 
Code: [Select]
(defun c:dwg ()
  (vl-cmdf ".undo" "m")
  (setq SS
(ssget "_x"
(list
  (cons 410 (getvar "ctab"))
  (cons 0 "MTEXT")
  (cons 7 "helv-meds-19")
  (CONS 8 "TITLE-BLOCK-TEXT")
)
)
  )
)

Since I like to fish, I know I caught some data but I don't know what kind of fish (data) it is and how do I cook it (pull the drawing number from it).  :-)
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 #20 on: July 13, 2006, 12:55:04 PM »
Once you get the entity name, then use entget to get the entity's code, then look at dxf code 1.
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 #21 on: July 13, 2006, 01:07:51 PM »
Potential problem with this:
(cons 410 (getvar "ctab"))
You must be in that active tab for it to work. If you are in Model space tab, no good.
Or if you are in a tab without a title block, no good.

If you know the name of the tab:
(cons 410 "tabname")
or this if you know the first letter
(cons 410 "N*")


So you may eant to remove that & then check the item to see if it is in paper space.
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 #22 on: July 13, 2006, 01:59:07 PM »
Once you get the entity name, then use entget to get the entity's code, then look at dxf code 1.

It took me awhile to get this.  I went fishing in the help section and came up with this.  Though I really dont know "how" it is doing it.
Code: [Select]
(defun c:dwg ()
  (vl-cmdf ".undo" "m")
  (setq ss
(ssget "_x"
(list
  (cons 410 (getvar "ctab"))
  (cons 0 "MTEXT")
  (cons 7 "helv-meds-19")
  (CONS 8 "TITLE-BLOCK-TEXT")
)
)
  )
  (setq name (ssname SS 0))
  (setq code (cdr (entget name)))
)

and it return this for the entget.
Code: [Select]
Command: dwg ((0 . "MTEXT") (330 . <Entity name: 7ebfad40>) (5 . "47F") (100 .
"AcDbEntity") (67 . 1) (410 . "Layout1") (8 . "TITLE-BLOCK-TEXT") (100 .
"AcDbMText") (10 34.0938 1.54018 0.0) (40 . 0.625) (41 . 2.01297) (46 . 0.0)
(71 . 5) (72 . 5) (1 . "{\\T0.9;A1.02}") (7 . "helv-meds-19") (210 0.0 0.0 1.0)
(11 1.0 0.0 0.0) (42 . 1.68555) (43 . 0.638021) (50 . 0.0) (73 . 1) (44 . 0.75))

Command: 'VLIDE

and you said take a look at dxf code 1
Code: [Select]
(1 . "{\\T0.9;A1.02}")
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 #23 on: July 13, 2006, 02:11:26 PM »
Code: [Select]
(cdr (assoc 1 (entget name)))

Now you will have to look at the formating strings for Mtext, so that you will only get the text itself and not all the formating.  This is available in the help docs.
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 #24 on: July 13, 2006, 03:37:16 PM »
Now you will have to look at the formating strings for Mtext, so that you will only get the text itself and not all the formating.  This is available in the help docs.

I give up, not finding it in help and I briefly look in the waters of the swamp.  The closest I could find is the Section "Format Multiline Text".  It tells me how to add formating to text but not on removing it.  Could you point me right direction of #$%@ Help Docs.

It took me sometime to figure out on how the formation got there in the first place.  I am the culprit.  Typically we use a 3 characters dwg number, but the project that I am currently assign to is so large. I had to go to a 4 characters dwg# and reduce the spacing between characters.
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 #25 on: July 13, 2006, 03:41:41 PM »
You are in the right spot.  It tells you how to add it, so now you know what to look for.  Here is a quick one I wrote.  It might get you going on the right path.  There is also code floating around the net for removing mtext formatting.  If you find one, you can steal (borrow) the portion needed to do your code.
Code: [Select]
(defun StripString (String / cstr1 cstr2 nString cnt1 tstr1)
; Strips out formation for color, font, height and width.

(setq cnt1 1)
(while (and (setq cstr1 (substr String 1 1)) (> (strlen String) 0))
 (if (= cstr1 "\\")
  (progn
   (setq cstr2 (substr String 2 1))
   (if (member (strcase cstr2) '("C" "F" "H" "W"))
    (progn
     (while (/= (substr String cnt1 1) ";")
      (setq cnt1 (1+ cnt1))
     ); while
     (setq String (substr String (1+ cnt1) (strlen String)))
     (setq cnt1 1)
    ); progn
    (progn
     (if nString
      (setq nString (strcat nString (substr String 1 1)))
      (setq nString (substr String 1 1))
     ); if
     (setq String (substr String 2 (strlen String)))
    ); progn
   ); if
  ); progn
  (progn
   (if nString
    (setq nString (strcat nString (substr String 1 1)))
    (setq nString (substr String 1 1))
   ); if
   (setq String (substr String 2 (strlen String)))
  ); progn
 ); if
); while
(setq tstr1 (vl-string->list nString))
(if (and (not (member 92 tstr1)) (member 123 tstr1))
 (setq tstr1 (vl-remove-if '(lambda (x) (or (= x 123) (= x 125))) tstr1))
); if
(vl-list->string tstr1)
)
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 #26 on: July 13, 2006, 03:53:51 PM »
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 #27 on: July 13, 2006, 03:56:36 PM »
Another stripper 8-)
You just wanted to say that.....
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 #28 on: July 13, 2006, 04:22:14 PM »
Yes  :-D

OK try this.
If you use the 410 you will not need the 67.
If you use the 67 then it will get all layouts if more than one.

Code: [Select]
(defun c:dwg ()
  (vl-cmdf ".undo" "m")
  (if
       (setq  ss
              (ssget "_x"
                       (list
                         (cons 0 "MTEXT")
                         (cons 7 "helv-meds-19")
                         (CONS 8 "TITLE-BLOCK-TEXT")
                         (cons 410 (getvar "ctab"))
                         ;'(67 . 1) ; in paper space but if you have >1 tab
                         '(-4 . ">=,>=,*")'(10 0.0 0.0 0.0)
                         '(-4 . "<=,<=,*")'(10 5.0 5.0 0.0)
                       )
              )
       )
    (progn
      (setq txt (cdr (assoc 1 (entget (ssname SS 0)))))
      (setq txt (strip txt)) ; use a mtext code stripper
    )
  )
)
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 #29 on: July 13, 2006, 04:37:36 PM »
:-o :-o :-o :-o :-o
 :cry: :cry: :cry: :cry: :cry:

All three suggested codes are huge for just formation that "should not" be there in the first place.   I still have to plunk it into my existing code.
Makes me rethink things again.
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