span8
span4
span8
span4
Text features,or labels,can be tricky to work with when translating between different formats,especially if you want to try and preserve some of the richer formattings like fonts,size,curved words and paragraph structure.In this article,we will look at how FME handles AutoCAD text features and explore some real-word examples.If you are finding that your labels are becoming unmanageable or you would like to try a different approach,it might be worth checking out theMapTextLabeller plugin,which you can try out forfree.
It is important to note that when inspecting AutoCAD data with the FME Data Inspector it will almost always look different to how it is displayed in your Autodesk application (especially text).As with all DWG transformations,it is strongly recommended that you view and verify any output DWG files with an applicable Autodesk application.Don't have one?you can use Autodesk's fantastic free online360 Viewer.
This article will look atAutoCAD entitiesof type:autocad_textandautocad_multi_text.
If you are familiar with AutoCAD you'll likely be aware that there are two main options available for creating text features in your DWG:
MText and Text features or entities as seen in AutoCAD 2017:Each simple text feature can only contain a single line whereas the MText feature includes all three lines.
Textis simple,single line text features with few properties.There are several things we can do with simple text in AutoCAD such as move,scale,rotate and stretch our words,however,we are somewhat limited in terms of style and each new line of text becomes a new feature.Simple text would not be used for writing larger blocks of text.
MTextfeatures provide extra functionality,they can contain multiple lines of text and they have the ability to contain several different fonts and styles within the same feature.In AutoCAD,MText features behave how you would expect typical word processors to behave.
OK,we've covered off AutoCAD,now let's look at how FME represents these different features.
All text features from DWG files are represented geographically by point geometry (including MText).This point is determined by the text insertion point.When reading text features from DWG,the most popular text properties such as,size (height),rotation and string contents are copied and converted to FME format attributes.These FME attributes are what the FME Data Inspector uses to visualise the features.
Note:There are a number of AutoCAD specific format attributes which arenotrecognised by the FME Data Inspector and is the reason why your DWG might look different in FME and AutoCAD.These attributes can be identified by the ‘autocad_' prefix and can be found in the Format Attribute window on the right-hand side of the FME Data Inspector.Each of the attributes can be modified with FME but will only be recognised by the AutoCAD writers.For more about AutoCAD format attributeshere.
Some interesting AutoCAD specific text attributes which are not recognised by the FME Data Inspector,but can still be modified include:
For a full list of AutoCAD specific format attributes which are applicable to Text features check out the Help Documentationhere
Before we get started on MText,let's take a look at a simple text example in FME Workbench.Let's convert some roads (attributed line features) from a geodatabase into a DWG file,and try to represent some of the attributes as simple labels in our output DWG and see what happens.
1.Download and openexample1.fmwt:
Example 1reads in the Roads feature type from our geodatabase,uses the Labeller to create two line labels from StreetId and StreetName.It uses an AttributeManager to create and set the ‘autocad_oblique' attribute and then finally writes out the roads and labels into a single Roads layer in our output DWG.Inspectors are placed just prior to the writer.Run the workspace and wait for the FME Data Inspector to load up.Zoom into one of the road labels and you will notice that the labels are displayed as two lines of text that are stored as a single text feature.
2.Run the workspace and wait for the FME Data Inspector to load up.Zoom into one of the road labels and you will notice that the labels are displayed as two lines of text that are stored as a single text feature.
3.Take a look at what has happened to the features after they were written out by the ACAD writer: Locate theOutput.dwgfile and open it in AutoCAD.You will notice that the two lines of text have been split out and written as two separate text entities.We can also verify that the text is also now oblique.
Output.dwg as seen in AutoCAD 2017: Each of the lines of text from our labels have been converted to single simple text entities,we can verify that the text features are also obliquing by a factor of 15 as was set in theAttributeManager.
OK now we're getting into the more challenging stuff.We've looked at simple text,so what about MText?
MText (or multi-text) is anAutoCAD entity(type:autocad_multi_text) which can handle richer formatting than the simple autocad_text entity.Formatting options include the ability to have multiple lines,multiple fonts,text wrapping,and bullet points,all within a single feature.FME can both read and write AutoCAD MText features,however,as with most AutoCAD entities,the appearance of such features will be different when viewed with the FME Data Inspector.
When adding a DWG reader to a workspace (and even when viewing features in the FME Data Inspector) it is always important to check the reader parameters,this is especially true when working with MText entities.When reading MText entities with FME,a user can choose to either explode their MText features into individual text entities (similar to exploding blocks which is covered inthis article),or keep the MText feature as one.
This option can be found in the reader parameters in the Entity Options section (see below).Choosing to explode your MText entities will split out each of the lines of text into separate text entities (this is the default).If you want to keep your MText as a single entity be sure to uncheck this box.
REALDWG reader default parameters:note thatExplode MText Entitiesis selected by default.
When an unexploded MText feature is read into FME it is treated similarly to a simple text feature,however,in order to preserve the richer formatting,additional format attributes are created.The most important being autocad_mtext_string.This format attribute carries theformatting code used by AutoCAD.This is important if you are writing out to AutoCAD DWG,which we'll see in an example below.
When inspecting an unexploded MText feature with multiple lines in the FME Data Inspector,you may notice that it is read as a single line,whereas in AutoCAD,it is read as several.This is because the text is wrapped in AutoCAD.The wrapping width is preserved within the format attributeautocad_mtext_ref_rect_width.Check out the FME help for more info onMText specific format attributes.
When FME explodes an MText feature it becomes a group of separateautocad_textfeatures which all share the sameautocad_entity_handleformat attribute.This is handy if you want to edit certain parts and then aggregate them back together.
Exploded vs unexploded MText in the FME Data Inspector:The green text has been exploded by the reader and each of the three lines from the MText entity are now treated as three individual features.The blue MText on the right is unexploded,note that we only see one line here (in AutoCAD is appears as three).
OK so now we know how to bring in MText features from a DWG file but you may be asking "how do I use FME to create cool MText features?"
The easiest way to create MText features is with theDWGStylertransformer.Example 2 shows this with a basic workspace.Example 2 performs a similar transformation to Example 1,however,this time our text will be written out as MText entities.
Example2: This is very similar to example1,however,we have swapped out the AttributeManager for a DWGStyler
DWGStyler parameters:A simple example of how to create MText features.In this example I have left the Text Size,Rotation and Text fields empty because the Labeller has already done this part for us.All we want the DWGStyler to do in this case is prepare the features so that the writer knows to save them as MText.
autocad_attach_point (encoded: utf-8)autocad_middle_centerautocad_entity (encoded: utf-8)autocad_multi_textautocad_mtext_string (encoded: utf-8){\fTimes New Roman|b0|i0;Pendrell StID: 11418}
**IMPORTANT**Remember to open up the result (Output_mtext.dwg) in AutoCAD to see the proper representation.Zoom in on a label and you will see that each is a single,two line MText entity centred on a road.The justification was set in the DWGStyler.For more information on justification check outthis article.
Text in AutoCAD:The result of example2 as seen in AutoCAD,a single MText entity centered on a road.
Intro: AutoCAD 亚搏在线workflows|Previous section: Give your DWG some style: Using the DWGStyler,template files,块和更多|Next: Working with AutoCAD layouts
Give Your DWG Some Style: Using the DWGStyler,template files,块和更多
Reading Basic Geodatabase Annotation - GDB to DWG
Working with Top10NL and AutoCAD
Viewing and Inspecting AutoCAD DWG Data: Grouping Entities
MicroStation Text Styles in FME 2015.0 and older
Basic DWG Block Handling Example: Preserving Block Entities (DWG to SHP)
© 2019 亚搏在线Safe Software Inc |Legal