These examples cover the basic FRED scripting commands involving curves: "Add" - add a curve or curve properties, "Get" - retrieve curve data, "Init" - initialize a curve structure, "Set" - set curve data.
The following structures are required for curve definitions and specific curve types:
Each curve type requires at least one structure be part of its definition.
"Add" a curve or curve data Adding a line curve requires two structures, T_ENTITY and T_LINE. Set the curve's basic properties with T_ENTITY. At a minimum, give the curve a name. If the curve will be used to generate a swept surface, then set traceable to False. Set other basic properties as needed. The starting and ending xyz points of the T_LINE structure should be initialized to avoid ambiguity. Set these to their desired coordinate values before adding the line. Issue and Update command to refresh the FRED document:
Dim cent As T_ENTITY Dim linedef As T_LINE InitLine linedef 'sets starting point to x=y=z=0 and ending point to x=1 y=z=0
cent.name="My First Line" cent.traceable=False
'new starting and ending xyz values linedef.startX=2: linedef.startY=3: linedef.startZ=0 linedef.endX=1: linedef.endY=1: linedef.endZ=1
line1id = AddLine ( cent, linedef ) Update
A segmented curve requires only one structure. An array must be declared and populated with the desired number of points and xyz values. In this example, a rectangular closed curve is created in the z=0 plane. This requires 5 xyz values to close the curve:
Dim segent As T_ENTITY segpoints(0,0)=0: segpoints(1,0)=0: segpoints(2,0)=0
In this example, a composite curve is made from three existing curves. The new composite curve is named then an array is declared and populated with the curve's identifiers before issuing AddCompositeCurve:
Dim compent As T_ENTITY id = AddCompositeCurve ( compent, compids ) Update
Aperture curves are used to trim surfaces. In this example, an aperture curve is created that uses three existing curves; one as a "Hole", one as a "ClearAperture" and one as an "Obscuration". The T_APERTURECURVOP structure contains the curve identifiers, their group number and the type of aperture for which each curve is to be used.
Dim apent As T_ENTITY 'curve identifier, group number and function cops(0).curv=5 :cops(0).group=1: cops(0).action="Hole"
"Get" curve data The "Get" commands retrieve data from curve entities. In this example, the parameters of a conic arc are loaded into declared structures (See the specific structures for information on what parameters they contain):
Dim conent As T_ENTITY Dim arc As T_CONICARC GetConicArc conid, conent, arc
The number of segments in a Segmented curve or the number of curves used in an aperture collection curve can also be retrieved:
nseg = GetSegmentedCurveSegCount ( segid )
or
numcurves = GetApertureCurveOpCount ( apcollid )
"Init" a curve structure Lines, circular arc and conic arcs require that their structures be initialized. This operation insures that values are assigned to all parameters in a structure.
Dim arc As T_CONICARC InitConicArc arc
"Set" curve data Define or alter existing curves with the "Set" commands. When editing a curve, a "Set" command should be used in concert with a "Get" command to insure only the desired changes are made. In this example, only the starting x & y-values and the D coefficient of the curve are changed:
Dim conent As T_ENTITY Dim arc As T_CONICARC GetConicArc conid3, conent, arc
'alter only these conic curve parameters arc.startX=arc.startX+0.1 arc.startY=arc.startY-0.1 arc.D=arc.D*1.1 SetConicArc conid3, conent, arc
In this example, the aperture collection defining a mask has one of it curves exchanged for another. Here, the curve will serve the same purpose as the one it replaces:
Dim apent As T_ENTITY
apsid=FindName("mask") GetApertureCurve apsid, apent, apcrv apcrv(1).curv=13 'identifier for curve to be substituted SetApertureCurve apsid, apent, apcrv See Also….
|