Autocad calculation using fields and blocks

While drafting in AutoCAD, sometimes we come to situation where we need to upadate some text based on values of other text (similar to using formulas as in excel). In such case we can use FIELDS of Autocad to do our calculations and update the drawings automatically.
Basics:
The basic method to use field is very easy. Try following steps to get the idea.
>>MTEXT (type some number say 151) and click ok
>>MTEXT>Instert Field (or directly use FIELD command) : a dialog box will appear as shown below
field.PNG
-Select Field category: Objects
-Field names: Formula
-In Formula filed: right click >insert field : this will open new field window (the idea is use field value within another field)
-In this new Filed dialog box choose
-Filed names: Objects
-Objet type:Select the Mtext with the input number
-Property:Contents
-Click Ok
field2.PNG
Now in the original window there will be some value like 151 at the end type *2 so the content will look like 151*2
-Click ok
The new Mtext will change to value showing 302.
-To edit the formula, double click the field.
Now if the first Mtext value is changed to 100 from 151 then after REGENERATEing the drawing. The field will show 200.

For blocks

The fields will work not only in Mtext but also in Block attributes, hence making life easy to create blocks which has multiple values based on some formula of few input parameters. For eg a scale block (as shown below). However, there are few differences. A sample method is given below using example of scale block:
scaleautocad.PNG
– Draw the shapes (lines, hatch etc)
-Define block attributes (name them L1, R1,R2,R3,R4,R5,SCALE) (i made SCALE as hidden so that it will not be visible and will be used for calculation only) also i made all tags prompting to “DO NOT EDIT” as you will see later as these values should be updated automatically).
-Create block using BLOCK command
Now double click the box to change attibute value (say for value of L1).
-in Value field >right click>edit field
Now the field dialog box appears as discussed above.
-Select formula in field name
-in formula right click >Add fileds
New field dialog box appears
-select Object in field names
-select the Block that you had just created in Object type
-all tags will appear in the property (L1, R1,R2,R3,R4,R5,SCALE)
-Chose the tag that you want to use (here SCALE). Click ok
Back in the formula write the required formula using this variable (eg 1000*50)
-Click ok
Close all the dialog box
Now if you change value of SCALE tag and regenerate, the value of L1 will change according to the formula specified.
Repeat the process for all the tags to get required value.


field2.PNG

Comments

Popular posts from this blog

http://sajanmaharjan.com.np/my-works/nepali-functions-addin-for-excel/

Nepali Calendar using php

Algorithm for Nepali date conversion