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

0 Members and 1 Guest are viewing this topic.

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Pulling information from a Field
« on: July 08, 2006, 07:43:44 AM »
Hello all,

I need some advice on fields to see if they can work in my automated plotting of PDFs.  I really know very little of what a field can do.  Spending a little time researching has shown that fields can pull information from some source.  What I want to do is reverse that and pull information from the field itself. 

Let me explain on what I am doing.  I have been using a lisp routines that I have created to speed up the plotting process.  (I don’t like batch plotting).  Since Autodesk finally come to their senses and included a PDF writer (IMHO worth the $500 subscription price) into the R2007, I can do (attempt) what I been wanting to do for a long time.   I want to pull the Drawing Number from our title block and feed that to the PDF writer when it asks for a name and a location.  The drawing number is the common denominator in all of my user projects.   File names change suit the needs of all the various types of projects we do and Layout tabs names are unreliable because of the users.

Can I use Fields to do this?  Fields are Mtext which is exactly what we use now for drawing numbers.   We xref our title blocks and use Mtext for the Drawing number, title and scale.  Would using an attribute be easier? 

Thanks in advance.
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

DEVITG

  • Bull Frog
  • Posts: 479
Re: Pulling information from a Field
« Reply #1 on: July 08, 2006, 06:21:14 PM »
Maybe if your dwg number [dwg#] is allways at the same location , you gan get it with a SSGET .

(setq dwg# (ssget (list xpt ypt)))

Also if your dwg# as a common prefix, and any other unique feature ,as the layer, linetype,textstyle or so,  it can be also get by a SSGET

(setq dwg#( ssget "x" (list (cons 0 "METEXT" ) (CONS 62 "DWG#COLOR") (CONS 8 "DWG#LAYER) (CONS 1 "DWG#*) (CONS 10 "DWG#INSERTIONPOIT) )))

(CONS 1 "DWG#*) will get any MTEXT that beguin with DWG#, and as it is only one MTEX that beguin with such prefix, it will pick it

Hope it help

Location @ Córdoba Argentina Using ACAD 2019  at Window 10

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Pulling information from a Field
« Reply #2 on: July 12, 2006, 09:58:25 AM »
Maybe if your dwg number [dwg#] is allways at the same location , you gan get it with a SSGET .

(setq dwg# (ssget (list xpt ypt)))

Also if your dwg# as a common prefix, and any other unique feature ,as the layer, linetype,textstyle or so,  it can be also get by a SSGET

(setq dwg#( ssget "x" (list (cons 0 "METEXT" ) (CONS 62 "DWG#COLOR") (CONS 8 "DWG#LAYER) (CONS 1 "DWG#*) (CONS 10 "DWG#INSERTIONPOIT) )))

(CONS 1 "DWG#*) will get any MTEXT that beguin with DWG#, and as it is only one MTEX that beguin with such prefix, it will pick it

Hope it help

Sorry I did not get back sooner.  I had one of those “we work all weekend and all night because they screwed up on schedule” projects.

You are saying to use DXF codes on the Mtext.  cool.  Never used it before but there is always a first.

Due to our loosey goosey standards, our users will have tweak the location or prefix due to the particular project.  Most of our drawings are have a prefix “A####” until we get to the cover page or if we do our own structural drawings.  The only option that I could use would be to change the DWG#’s layer to different layer.  Another thought is to change the color from ByLayer to different color.   But that means changing all the current drawings to this new “standard”.

What DXF code reads and returns the contents of Mtext?
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 #3 on: July 12, 2006, 12:05:44 PM »
Code: [Select]
(CONS 1 "DWG#*)
In you example use this with the example above (CONS 1 "A####") and will return only the mtext with a WCMATCH of
"A" plus four number characters.
« Last Edit: July 12, 2006, 12:09:56 PM by CAB »
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.

DEVITG

  • Bull Frog
  • Posts: 479
Re: Pulling information from a Field
« Reply #4 on: July 12, 2006, 12:53:38 PM »
I have a type error here

(setq dwg#( ssget "x" (list (cons 0 "METEXT" ) (CONS 62 "DWG#COLOR") (CONS 8 "DWG#LAYER) (CONS 1 "DWG#*) (CONS 10 "DWG#INSERTIONPOIT) )))

It shall be so.

(cons 0 "MTEXT")

Location @ Córdoba Argentina Using ACAD 2019  at Window 10

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: Pulling information from a Field
« Reply #5 on: July 13, 2006, 09:06:32 AM »
Code: [Select]
(CONS 1 "DWG#*)
In you example use this with the example above (CONS 1 "A####") and will return only the mtext with a WCMATCH of
"A" plus four number characters.

Sorry CAB that want work. Take a look at the pictures.  Our drawing prefixes change with the type of sheet it is placed on.  For example, TP for Title page.  And the number of characters change too.  It is always in a general location, but the actual insert point could vary depeding on the nuiances of the user doing the inserting and/or it could be two lines (word wrap) of text
« Last Edit: July 13, 2006, 09:13:32 AM by Krushert »
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 #6 on: July 13, 2006, 10:03:55 AM »
Well be creative in your approach. 8-)
Expanding on DEVITG's example:

Code: [Select]
(setq dwg# ( ssget "x" (list (cons 0 "MTEXT" )  (cons 8 "DWG#LAYER) (cons 1 "A#*,TP") )))
Where (cons 1 "A#*,TP") will WCMATCH any mtext that starts with a capital 'A' followed by one number and anything that may follow.
AND any mtext that has only the capital 'TP' as its value.

The example above uses only LAYER to narrow the selection. You may want to add more restrictions.
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 #7 on: July 13, 2006, 10:47:54 AM »
Well be creative in your approach. 8-)
Expanding on DEVITG's example:
Code: [Select]
(setq dwg# ( ssget "x" (list (cons 0 "MTEXT" )  (cons 8 "DWG#LAYER) (cons 1 "A#*,TP") )))

Where (cons 1 "A#*,TP") will WCMATCH any mtext that starts with a capital 'A' followed by one number and anything that may follow.  AND any mtext that has only the capital 'TP' as its value.
I am leary of using this approach because all the different types of prefixes:  S's, APs, the list goes on.

The example above uses only LAYER to narrow the selection. You may want to add more restrictions.
Aha now I am seeing how this is working.  What is the code fof Mtext height? The text height is inserted at 5/8" in height.  Just to make make not so restrictive, can I have some filtering?  For example, (cons ?? "9/16<*>11/16").  The  DWG# is the only text that is 5/8". 

This brings up another question, will this search both model space and paperspace? or just current space?
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 #8 on: July 13, 2006, 11:05:09 AM »

Code: [Select]
.... ( ssget "x" (list ......
When the routine reads this; what will it do?
« Last Edit: July 13, 2006, 11:21:53 AM by Krushert »
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 #9 on: July 13, 2006, 11:19:57 AM »
You need to decide weather there is enough unique properties of the mtext to be able to reliably find it in the drawing.

So please list it's unique properties:
Layer
Style
Text Height is not usable in mtext but ok for dtext
Color if not 'By Layer', must be an override
Insert Point - you ruled this out
Text String - varies
space - paper or model or current

More on text string, if the text is unique you can often use wcmatch to filter for it.

You need to explore ssget filters and wcmatch.

And in the end this may not be a viable solution for your problem but I suspect it is.
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 #10 on: July 13, 2006, 11:31:35 AM »
From the help file
Quote
Creates a selection set from the selected object
(ssget [sel-method] [pt1 [pt2]] [pt-list] [filter-list])

Selection sets can contain objects from both paper and model space, but when the selection set is used in an operation, ssget filters out objects from the space not currently in effect. Selection sets returned by ssget contain main entities only (no attributes or polyline vertices).

Arguments

sel-method

A string that specifies the object selection method. Valid selection methods are:
C  Crossing selection.
CP  Cpolygon selection (all objects crossing and inside of the specified polygon).
F  Fence selection.
I  Implied selection (objects selected while PICKFIRST is in effect).
L  Last visible object added to the database.
P  Last selection set created.
W  Window selection.
WP  WPolygon (all objects within the specified polygon).

X  Entire database. If you specify the X selection method and do not provide a filter-list, ssget selects all entities in the database, including entities on layers that are off, frozen, and out of the visible screen.
:E  Everything within the cursor's object selection pickbox.
:N  Call ssnamex for additional information on container blocks and transformation matrices for any entities selected during the ssget operation. This additional information is available only for entities selected via graphical selection methods such as Window, Crossing, and point picks.

Unlike the other object selection methods, :N may return multiple entities with the same entity name in the selection set. For example, if the user selects a subentity of a complex entity such as a BlockReference, PolygonMesh, or old style polyline, ssget looks at the subentity that is selected when determining if it has already been selected. However,  ssget actually adds the main entity (BlockReference, PolygonMesh, etc.) to the selection set. The result could be multiple entries with the same entity name in the selection set (each will have different subentity information for ssnamex to report).

:S   Allow single selection only.

Some examples

(ssget "X")    ; get the entire database
(ssget "ALL") ; filters out frozen layers

;;  Limit the _X filter to current tab model space which ever is active
(setq ss (ssget "x" (list (cons 410 (getvar "ctab")))))
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 #11 on: July 13, 2006, 11:48:22 AM »
You need to decide weather there is enough unique properties of the mtext to be able to reliably find it in the drawing.
So please list it's unique properties: 

Layer  see code
Style   I could use this
Text Height is not usable in mtext but ok for dtext  Just an Idea
Color if not 'By Layer', must be an override  Color is Bylayer
Insert Point - you ruled this out  Correct but how about general position  see code
Text String - varies   correct.  we pdf everything and we create special docs for whomever for example there is now a conversation pertaining to Condo Docs.
space - paper or model or current  I "want" paperspace.  if my user places a titleblock in the model, he can pdf the old fashion way and afterwards, I will have more painfull torture for him/her.  :pissed:[/quote]

You need to explore ssget filters and wcmatch. 
  Currently going down this path, and I think i found something.
And in the end this may not be a viable solution for your problem but I suspect it is.
  I suspect too.  and if not, no big deal because I am having fun trying to figure it out.

This is what I got so far.  Tested and return a "nil" for "dwg#".
Code: [Select]
(defun c:dwg ()
  (vl-cmdf ".undo" "m")
  (setq dwg#
(ssget "_W" '(0 0) '(5 5)
(list
  (CONS 0 "MTEXT")
  (CONS 8 "TITLE-BLOCK-TEXT")
  )
)
)
  )
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 #12 on: July 13, 2006, 11:59:01 AM »
One problem with window or crossing, is that the area you are using has to be on screen.  In other words if you don't see the lower right hand corner of your title block, it won't select anything.

/back to regularly scheduled program.
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 #13 on: July 13, 2006, 12:06:44 PM »
oops! wrong coodinates in code.  now I get "<Selection set: 4d1>"


One problem with window or crossing, is that the area you are using has to be on screen.  In other words if you don't see the lower right hand corner of your title block, it won't select anything.

/back to regularly scheduled program.

Hmmm this makes me think. 
The Existing Routine that I will be modifing with this excerise performs a "Zooms-Extents".  So I dont think it will be a problem.  But I dont know if I want to rely on that.  Something is making me itch about that.
« Last Edit: July 13, 2006, 12:12:26 PM by Krushert »
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 #14 on: July 13, 2006, 12:09:26 PM »
Another option is to search for all the mtext objects on that layer, and then sort the selection set by coordinates.  If text you want is always the right most, and lowest text then it can be easy.  I have done this before.

< sorry if stepping on any toes >
Tim

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

Please think about donating if this post helped you.