Example Macros
Overview
The following are some example macros:
For more examples of macros, see:
■The examples directory in the Adams View installation area.
Create Marker Macros
The following macros create coordinate system markers between existing markers. They differ only in how the newly created marker is oriented.
Example 1 - Macro to Create Marker Midway Between Two Existing Markers
The macro shown below creates a new marker at a location midway between the location of two existing markers. It creates the new marker so its orientation is the same as the global coordinate system's.
The macro expects you to specify three parameters when you execute the macro, as indicated by the three names preceded immediately by a dollar sign ($). Note that the three parameters used by the macro are defined up front, at the beginning of the macro, before they are ever used in an executable Adams View command. Defining macro parameters at the beginning of a macro allows you to explicitly declare a type for each parameter. The T=marker or T=new_marker string associated with the parameters indicate that a user can only specify an existing marker or a new marker, respectively, for that particular parameter. Although declaring the type in advance is not required, we recommend it.
! $FIRST_MARKER: T=marker
! $SECOND_MARKER: T=marker
! $NEW_MARKER_NAME: T=new_marker
!
marker create marker_name=$NEW_MARKER_NAME &
location = (( ($FIRST_MARKER.loc_x)+($SECOND_MARKER.loc_x) )/2 ),&
(( ($FIRST_MARKER.loc_y)+($SECOND_MARKER.loc_y) )/2 ),&
(( ($FIRST_MARKER.loc_z)+($SECOND_MARKER.loc_z) )/2 )&
orientation = 0,0,0&
relative_to = ground
Example 2 - Macro to Create Marker Midway Between Two Existing Markers (Variation)
The macro shown below is similar to the first macro example in that it creates a new marker midway between two existing markers. It, however, directs the new marker's z-axis so it points from the first marker towards the second marker. The two markers that a user specifies must both belong to the same part and to the same part as the new marker being created.
!$FIRST_MARKER: T=marker
!$SECOND_MARKER: T=marker
! $NEW_MARKER_NAME: T=new_marker
!
defaults orient_axis_and_plane axis_and_plane_setting=z_axis_zx_plane
!
marker create marker_name=$NEW_MARKER_NAME &
location = ((($FIRST_MARKER.loc_x)+($SECOND_MARKER.loc_x))/2), &
((($FIRST_MARKER.loc_y)+($SECOND_MARKER.loc_y))/2), &
((($FIRST_MARKER.loc_z)+($SECOND_MARKER.loc_z))/2) &
along_axis = $FIRST_MARKER, $SECOND_MARKER &
relative_to = ground
Create Extrusion Macros
The following macros extrude existing geometry. They differ only in how you specify the path of the extrusion.
Example 3 - Macro to Extrude Geometry Along Specified Z-axis of a Specified Marker
The following macro helps you create an extrusion from an existing curve that you specify. When executing the macro, you specify a real number for the length for the extrusion as well as the name of an existing marker along whose z-axis the curve will be extruded. The macro automatically makes the new extrusion geometry belong to the same part as the curve geometry that you also specify. It supplies a unique name for each new extrusion, such as EXT_1, EXT_2, and so on.
! $curve_to_extrude: T=geometry
! $extrusion_length: T=real
! $along_Z_axis_of_marker: T=marker
defaults model part_name=($curve_to_extrude.parent)
!
geometry create shape extrusion &
extrusion_name=(UNIQUE_NAME("EXT"))&
profile_curve=$curve_to_extrude&
length_along_z_axis=$extrusion_length&
reference_marker=$along_Z_axis_of_marker&
relative_to=ground
Example 4 - Macro to Extrude Geometry Along Reference Marker of Curve
The following macro is identical to the third macro example, except it automatically sets the direction along which the extrusion will occur to that of the z-axis of the reference marker of the curve. In this case, you only need to specify the curve to extrude and the extrusion’s length to execute the macro.
! $curve_to_extrude: T=geometry
! $extrusion_length: T=real
!
defaults model part_name=($curve_to_extrude.parent)
!x
geometry create shape extrusion&
extrusion_name=(UNIQUE_NAME("EXT"))&
profile_curve=$curve_to_extrude&
length_along_z_axis=$extrusion_length&
reference_marker=($curve_to_extrude.ref_marker_names)&
relative_to=ground