Meta data

Meta data

timothy.birdwell
Enthusiast Enthusiast
2,430 Views
8 Replies
Message 1 of 9

Meta data

timothy.birdwell
Enthusiast
Enthusiast

  I was given a file yesterday and they want all the Mtext to be placed in the object data. The object is already existing in the drawing, but the data fields are blank. The text next to the object is the data that needs to go there. Is there a way to transfer the mtext out as a shape file and import it back in as the object data? Right now I am seperating the text into different layers that correspond to the object.

0 Likes
Accepted solutions (1)
2,431 Views
8 Replies
Replies (8)
Message 2 of 9

ChicagoLooper
Mentor
Mentor

Hi @timothy.birdwell 

Maybe yes. Maybe no. It all depends on your data and your objects.

 

You didn't explain how the attribute data is compiled. Is it plain mtext? Is it in a spreadsheet? Can you, or a colleague, put it in a spreadsheet? Is the data numeric, alpha or both? Is the data uniform throughout the drawing, meaning all six lines (however many there may be) are filled in without any blanks? Sorry, but your explanation is vague. Provide a thorough explanation for a thorough answer. Better yet upload your data.

 

You also didn't explain the nature of your 'object(s).' Is it a block? Is it just one block? Or several blocks? If it's not just one block, what is the criteria to use this block as opposed to that block? Do all blocks have the same attributes? What do the blocks represent?

 

For a detailed answer, provide a detailed explanation, and if possible, include pictures. Even better is to upload your block and the data you'd like to attach.

Chicagolooper

EESignature

0 Likes
Message 3 of 9

timothy.birdwell
Enthusiast
Enthusiast

@ChicagoLooper  So the data is just plain mtext written in the drawing, the objects are blocks. So the blocks are not geolocated and have no data contained within them. I am placing the Mtext at the blocks insertion point so I can create an x,y relationship with it. I then plan to export the mtext out as gis data and import it back in as a block to contain this information. Just wondering If I can do it like this, the other option is to type everything into the existing blocks. I had attached 2 images in the first post. We do use Map 3D, but I haven't seen anyone using the features of it or very little knowledge to. I hope this can clarify it for you.

0 Likes
Message 4 of 9

ChicagoLooper
Mentor
Mentor

Hi @timothy.birdwell 

I’m sensing a bad, inefficient workflow. If you’re openminded, you’ll avoid that procedure then find and adopt a new one.

 

If you treat the mtext as a single piece of data, then that’s all you’ll have, a ‘smart block’ with one piece of data. What you really want is separate pieces of data such as (I’m making this up, of course) size, part #, material, date installed, vendor, cost. Separation allows you to run analyses. For example all parts beginning with ‘BMP04’ or number of PVC units vs. stainless steel units or most common size needing replacement. 

Your idea to export the mtext as GIS data then import the same data back doesn’t accomplish anything meaningful. 

However, your workflow starts nicely, very nicely, because you move the mtext directly onto the insertion point of the block and this enables you to harvest the spatial position of the text entity. After moving the mtext, though, the workflow loses it’s direction and seems lost.

 

A more powerful way would be to extract (1) the x,y coordinates and (2) the ‘content’ of the mtext where the content captures each individual line of text and captures them separately.

 

If your proficient with spreadsheets you can invest some time in copying-and-pasting your mtext to excel, then using know-how, separate the text by arranging the text

parts into individual cells. This investment will yield big dividends later. Each row of the spreadsheet would represent a location (or a block) and and each column would correspond to the various attributes, i.e, one column for part#, another column for vendor and another column for cost, etc. etc. You can insert the northing and easting of each location into columns too so they’ll work hand in hand with the tabular data. 

Upload a sample of your data with an explanation of what you’re trying to achieve. 

Chicagolooper

EESignature

0 Likes
Message 5 of 9

timothy.birdwell
Enthusiast
Enthusiast

Hi @ChicagoLooper

"Your idea to export the mtext as GIS data then import the same data back doesn’t accomplish anything meaningful." Yes found this out the hard way, it did accomplish getting me my x,y data and the mtext; all mtext in one cell though. After finding this out I did start a new spread sheet to separate the data. Now I didn't see away to capture each MText line separately. It placed all the text in a singe cell which looked like this 'PED 41_2-42L/005\PBDO7\PBM2\P1-HO-1\PMPT TERMINAL.

As far as workflow. I am the newest in the company and catch these drawing at the end due to my speed and accuracy. Also this company has merged with a bigger one as well and I believe the current drawing im working on is from an office not in our state. My manager was informed that this was easy and can be automated. So I asked him to send an email asking for the data tables so I can in fact finish this in under 10 minutes, but if not it is over 6,200 data objects which will take a lot of time.

I am an Architect in a sea of engineers, so most of the things I am doing in the drawings I don't know what they are, well now I have a better vague Idea of what it is. Thank you so much for your time it has been helpful keeping me up with the learning curve here. attached is photos of the Xcel also a dwg with one block and one Mtext. What we are trying to do is place each line of Mtext in Block:fiber_ped in descending order. The values can be in any order so they would not have to be bound to a specific field.

0 Likes
Message 6 of 9

ChicagoLooper
Mentor
Mentor
Accepted solution

Hi @timothy.birdwell

We are making a little progress. A final solution cannot be made without further development.

Save your x,y coordinates. The coordinates are important and you can get back to them later.

For now, do this:

  1. Using your the drawing you uploaded in post #5, select the red mtext. Using your mouse, highlight all 7 lines of the text=>right click=>Copy.
  2. Open a clean, brand new spreadsheet=>highlight cell A1=>Paste <<Cells A1 through A7 will be filled in. Each cell will be occupied with a different line of mtext. It separates to different cells because you used the RETURN key when you were entering the mtext in AutoCAD.>>
  3. Still in your spreadsheet, select cells A1 through A7=>copy=>highlight cell A10=>Paste dropdown arrow=>click Transpose icon <<The data will PIVOT. This means the rows will become columns and the columns will become rows. The data will continue to be in separate cells. Refer to image-1 below. BTW, the blue arrows in the icon indicates a pivot type of operation.>>

Image-1Image-1

Notes for additional workflow:

Continue using the same uploaded drawing from post #5. Make additional copies of the red mtext. To differentiate the mtext from one another, edit line 2 so it reads BD05 for first mtext, BD06 for second mtext, and BD07 for the third. <<Editing line 2 is to make this example less confusing by giving each mtext a unique value in line 2. In actual practice you wouldn't be editing line 2.>>

  1. Copy and paste BD05 to spreadsheet cell A1. Next, back in modelspace, copy and paste BD06 to spreadsheet cell B1. Finally copy and paste BD07 to cell C1.
  2. Highlight cells A1 through C7=>copy
  3. While still in the same spreadsheet=>highlight cell A15=>Paste dropdown arrow=>click Transpose icon
  4. Optional: Highlight the letter 'A' at the top of column A (the entire column will now be highlighted))=>right click=>Insert=>Repeat this insert procedure again so you'll have two new blank A and B columns. <<Refer to image-2 below.>>

Image-2Image-2

The two new blank columns A and B will be for your x- and y-values. You'll need to insert the 'correct' coordinates for each line in your new Pivot Table. There are ways to insert the correct coordinates so they correspond to the correct data row but it's not covered in this post. You may now delete all 'rows above' your new Pivot Table, you don't need them anymore. If you wish, you may also insert a new blank ROW above the Table so you can insert descriptive column HEADERS.

@timothy.birdwell

Do you run any other programs besides Autodesk? Besides Map 3D? Any programs with geospatial capabilities? If you do, your workflow may change for the better.

Chicagolooper

EESignature

0 Likes
Message 7 of 9

timothy.birdwell
Enthusiast
Enthusiast

Hello @ChicagoLooper

Wow that is a big time saver, I never knew you could flip the cells like that. The naming theme is the PED, which will be deleted and 41_1-66s/08 will be the nomenclature. As far as other programs we use, at our company its Map3D and Google Earth. Other branches will use ArchGis and plexearth, but I don't have access to those. Your explanation of this is phenomenal, I've also been watching your screen casts for tips.

0 Likes
Message 8 of 9

ChicagoLooper
Mentor
Mentor

Hi @timothy.birdwell 

OK. We're making progress but we still haven't reached our destination. Because you haven't shared your actual dwg file, I'll have to guess regarding the nature of your drawing and how it behaves. Here's more info that may or may not be compatible with your specific drawing. The instruction below is pure guesswork. <<Before beginning this workflow, go to command line and enter UNITS=>change the Precision to 6 decimal places (click the dropdown arrow to change it). The default is only 4 decimals. You may change it back to 4 after this exercise.>> 

 

Run DATAEXTRACTION command. Go to Annotation tab=>Tables panel=>DataExtraction icon. This command makes you run through an 8-page 'Wizard.' The numbers below correspond to each page of the wizard.

  1. Name and save a brand new .dxe file. This file is used by AutoCAD to extract compile the data in your dwg file. For organization purposes, create a subfolder named Dataextraction and save the new dxe in there.
  2. Select the radio button named Select objects=>click the square button on the right of the radio button=>select all your red mtext. <<It helps if you isolate the layer hosting all the red mtext . You only want to select your red mtext. If you select other objects besides the red mtext, then you'll have extra data that you won't need b/c you only need to extract data for the red mtext and not for other objects that you have no use for.>> 
  3. Check only the box for mtext. If you see other boxes that are checked, uncheck them. 
  4. For Category File on the right, check only the boxes named (1) geometry and (2) text. For the Properties Section on the left, check only the boxes named (1) contents, (2) Position X and (3) Position Y. You don't need to check any other boxes in the Properties section.
  5. Based on your parameters you established on pages 1 thru 4, a sample of your extracted data is shown here on page 5. FYI, the Contents column will be deleted later, but for now, keep the Contents column. Under the sample view, in lower left, select only Combine Identical Rows. Deselect or uncheck (1) count and (2) show name, you don't need those options. Still on page 5, click 'Full Preview' button. This is a preview of your extracted data. Click on the 'Y' in the column named Position Y. The values will sort from lowest to highest. The values will toggle from ascending to descending with each click. You will want to sort the Y-values so highest value is in top row and lowest value is at bottom. Click the 'X' in upper right corner to exit this preview.
  6. You have two options to save your extracted data: (a) save it internally as an AutoCAD table which you insert directly to your drawing or (b) as an external file. Choose the output that's an external file. Save is to .xls format. <<Sorry, but there's no option for .xlsx.>>
  7. There won't be a Page 7. The page is skipped because you're saving to external file. If you choose to insert a Table directly (internally) in your dwg file, then page 7 would establish the format for that table.
  8. Click Finish button.

Open the new xls file. The Y-values should be in descending order or highest Y at top and descending to the lowest Y at the bottom, if it's not, you'll need to use an Excel command to sort it properly. Back in you dwg file, you can eyeball the red mtext objects to determine the order which you will select them. You want to select each mtext individually beginning with the mtext that's closest to the top of your monitor, the highest Y-value. <<Disregard each mtext's X-value, focus only on the Y.>> You'll want to copy an individual piece of mtext then paste it to a NEW spreadsheet (refer to earlier post) in cell A1. Back in you dwg, select the next highest Y-value of mtext or the 'second' closest to the top of your monitor then copy and paste it to cell B1. Then the 3rd highest Y is copied and pasted to cell C1. Continue for all of your red mtext objects. Once all the red mtext has been pasted, perform the PIVOT operation that was described in a previous post. After the Pivot, insert two 'blank' columns on the extreme left. Once inserted, they'll be named column A and column B and both will be empty.

 

Next, go to your DataExtraction file and copy the coordinates, or the values in the columns named Postion X and Position Y, and paste them (insert) them into the 'blank' columns you created in the previous paragraph. Name and save this xls file and give it to a member of your GIS team, preferably the team member you go out to lunch with. Tell him/her you want a shapefile (POINT feature class) using the spreadsheet. Any capable GIS'er will be able to create your shapefile while standing on their head with one hand tied behind their back. 

 

When the shapefile is delivered to you, save it in a brand-new subfolder named 'Project Shapefile' within your project folder. At the absolute bare minimum, this means barest-of-all-bares-known-to-every-two-legged-upright-walking-creature, you'll have three components: (1) shp, (2) dbf and (3) shx. Make sure you save all components in the same Windows folder. If you had a Geospatial Projection in your original dwg file, you'll have a fourth file named prj and it must be saved in the folder named Project Shapefile. 

 

Drag-and-drop the shp: DRAG the .shp from its Windows folder and DROP it directly onto modelspace. <<Perform the drag and drop s-l-o-w-l-y. AutoCAD is processing the shapefile in his brain while you're dragging and you don't want to rush him.>>

 

Hopefully this shapefile will work. Remember, all of this is pure guesswork. If it really does work, then your shapefile is good. And if it's good, then you can turn off, or disconnect from, the shapefile and use MAPIMPORT command. <<BTW, if this doesn't work, then Plan B is to use Overlay Analysis, an operation within Map3D. Overlay analysis is yet another way to associate your the red mtext data with a specific object.>> 

 

When the MapImport command is properly used on a 'good' shapefile, it's capable of doing 2 things: (1) placing the points of your shapefile in their correct location and (2) CREATING Object Data which is data you harvest from the shapefile's database file (dbf). The Object Data associated with a point can be viewed by selecting an individual point then scrolling to the bottom of the Properties Palette. <<The process of creating Object Data is not covered in this post. Neither is the process of using an AutoCAD block instead of using and AutoCAD 'point' to represent each individual location.>> 

 

Chicagolooper

EESignature

0 Likes
Message 9 of 9

timothy.birdwell
Enthusiast
Enthusiast

@ChicagoLooper 

  So I ended up having to do it manually. There was another person working on the file, and the file I was given was of course the outdated one. My finger tips and palms where numb and my wrists and arms hurt like heck. The silver lining to all this was I learned multiple way of achieving what I needed thanks to you and some coders. Which achieved the data entry, no need to make one to create latitude and longitude.

;;To quickly label Mtext into objects                       ;;
;; Type foo to start the command select the Mtext and object;;
(defun c:foo (/ b j m o p r s x)
  ;; String to List  -  Lee Mac
  (defun lm:str->lst (str del / pos)
    (if	(setq pos (vl-string-search del str))
      (cons (substr str 1 pos) (lm:str->lst (substr str (+ pos 1 (strlen del))) del))
      (list str)
    )
  )
  ;; RJP » 2022-12-02
 (defun _foo (str)
  (while (vl-string-search "\n" str) (setq str (vl-string-subst "\\P" "\n" str)))
  (cond	((wcmatch str "PED *") (substr str 5))
	((wcmatch str "VAULT *") (substr str 7))
	(str)
  )
)
  (cond	((setq s (ssget	'((-4 . "<OR")
			  (0 . "MTEXT")
			  (-4 . "<AND")
			  (0 . "INSERT")
			  (2 . "Fiber_Ped,*vault*")
			  (66 . 1)
			  (-4 . "AND>")
			  (-4 . "OR>")
			 )
		 )
	 )
	 (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	   (setq o (vlax-ename->vla-object e))
	   (if (vlax-property-available-p o 'textstring)
	     (setq m (cons (list (vlax-get o 'insertionpoint)
				 (lm:str->lst (_foo (vlax-get o 'textstring)) "\\P")
			   )
			   m
		     )
	     )
	     (setq b (cons (list (vlax-get o 'insertionpoint)
				 (mapcar '(lambda (x) x) (vlax-invoke o 'getattributes))
			   )
			   b
		     )
	     )
	   )
	 )
	 (foreach bl b
	   (setq p (car bl))
	   (setq m (vl-sort m '(lambda (r j) (< (distance p (car r)) (distance p (car j))))))
	   (mapcar '(lambda (r j) (vla-put-textstring r j)) (cadr bl) (cadr (car m)))
	   (setq m (cdr m))
	 )
	)
  )
  (princ)
)

 

0 Likes