Detailed Drawings > Running Drawing Programs > About Creating Drawing Programs
  
About Creating Drawing Programs
Using the Tools > Drawing Program commands, you can create a drawing program to define how a drawing will adapt to a change in the state of its model. Changes might occur when you re-execute the model with new Pro/PROGRAM inputs, or replace it with another instance from a family of models. Typically, you can distinguish one sequence, or state, from another by the values of some of the parameters in the model.
A drawing program is intended to be used to adapt a drawing to a part or assembly program. It contains logic statements that control the drawing layout and perform various detail functions. For example, a part drawing might include a detailed view of a particular feature, such as a keyway. If you suppress that feature, the system should erase that detailed view, and move the other views to fill the space. If you make a state such as no_detail_view that erases the detailed view and organizes (moves) the other views appropriately, the program queries the system to determine if the keyway is suppressed. If so, the drawing displays the no_detail_view state. If not, the drawing displays the detailed views of the model.
A drawing program has two portions: states and program text. A state is a named sequence of familiar procedures, such as showing a dimension or moving a view, that you perform on a drawing to define how it should appear. It is a record of modifications that you would like to make to the drawing. To create a state, you type a name and then record various detail commands. You can play back these commands to determine what the drawing state actually does, and then edit it, if necessary. As you create a drawing, you can create additional states and delete others.
You can place dimensions, dimension breaks, and dimension clips on snap lines during the creation of a drawing program state.
Once you have defined the drawing states, you can create a drawing program, as shown in the preceding figure. The drawing program is a text file, embedded inside the drawing, which contains lines of text that set certain states for the drawing, depending on the values of the conditional expressions that you use. You can use IF statements, drawing parameters, and assignment statements to set previously defined drawing states. The program first searches the drawing for a drawing parameter; if it does not find a parameter, it searches the default model for a model parameter. If the drawing program recognizes the drawing parameter, it designates it with the suffix ":d" (that is, drawing_attribute:d). If it is a model parameter, it designates it with the model number.
Commands to execute a drawing state take the following form: SET STATE name_of_state.
You can nest IF statements in the following form:
IF <expression>
ELSE IF <expression>
ELSE
ENDIF
An expression is a logical expression that you could use in a part relation. It could contain drawing attributes (as found in the SET UP menu) or the feature suppressed function (that is, FEAT_SUPPRESSED (model_name, feat_id) to determine if a feature is suppressed; and FEAT_SUPPRESSED (assembly_name, comp_id) to determine if a component is suppressed). For example:
IF FEAT_SUPPRESSED (bolt,15)
SET STATE no_detail_view
In this case, the system checks to see if feature ID 15 of the model named "bolt" is suppressed. If so, it sets the state to no_detail_view; otherwise, it does nothing.
Assignment statements take the following form:
var_name= expression, where var_name is a variable name.
Comment lines take the following form:
/*This is a comment line.
 
* The words IF, ELSE, ENDIF, SET, STATE, FEAT_SUPPRESSED are reserved. You cannot use them as variable names in a drawing program. Also, if using the equal sign (=) in an IF statement, use "==". If using a statement to set a parameter value, use "=".