How to add tex in a box

  XML_API > CAD XML API Reference > How To >

How to add tex in a box

Previous pageReturn to chapter overviewNext page

Sometimes it is needed to mark up the drawing with a text. Let us see how to create text in a box:

The following code example creates rectangle, hatch inside it and add text. 

                    

<?xml version="1.0" encoding="UTF-8"?>
    <!-- Description: Example show how to create text in a box and how to use list of handles. -->
<cadsofttools version="2">
  <!-- Create simple rectangular Solid Hatch. Handle of polyline is saved as "@1" -->
  <add>
    <cstLWPolyline HandleSave="@1">    
    <SubEntities>                 
    <cstVertex Point="0,0,0"/>      
    <cstVertex Point="2,0,0"/> 
    <cstVertex Point="2,1,0"/> 
    <cstVertex Point="0,1,0"/> 
    <cstVertex Point="0,0,0"/>      
    </SubEntities>
    </cstLWPolyline>
  </add>
    <!-- Select polyline -->
  <Select Handle="@1"/>    
    <!-- Create hatch -->
  <createhatch/>
    <!-- Set red color, it's index is 1 -->
  <apply Color="0;1;"/>
 
<add>  
    <!-- Create text in box -->
    <cstMText Point="0.2,0.6" Height="0.2" TextValue="Text in a box" HandleSave="@2"/>
</add>                      
  <ShowSelectedEntities/>
    <!-- Handles can be accepted as a list with ";" separator -->
  <UnSelect Handle="@1;@2;$24"/>        
</cadsofttools> 

Go to ABViewer