These examples cover the FRED Linear Transform Primitives scripting commands: "Add" - add an operation to be defined, "Delete" - deletes an operation, "Get" - gets operation or coordinate system info, "Lock" - allows/prevents update of linear transforms, "(Re)Start" - sets coordinate system for all operations, "Place" - appends a PlaceAt operation, "Rotate" - appends a Rotate operation "Shift" - appends a Shift operation "Transform" - transforms vectors from one coordinate system to another.
The structures listed below contain parameters required for linear transform primitive commands:
"Add" an operation The command AddOperation is one method of appending a linear transform operation to a specific entity. In the following example, a "ShiftZ" operation is appended to the entity "Mirror1":
Dim tp As T_OPERATION
"Delete" an operation Use this command to delete an existing operation from a specific entity. For instance, to delete the last operation associated with "Mirror1", use the following script lines. Remember that the operations are zero-indexed. As a result, it is necessary to subtract 1 from the entity count to get the index of the last operation.
id=FindName("Mirror1")
"Get" an operation The information associated with a specific operation can be retrieved using GetOperation. The GetOperationCount command returns the number of operations associated with a specific entity. In the following example, these commands are used together with DeleteOperation to determine if "Mirror1" has a "ShiftY" operation and, if so, to delete it:
Dim op As T_OPERATION
"Lock" an operation When an operation is changed or added, FRED immediately performs an internal update of a general matrix describing entire collection of linear transforms. For large models, this immediate updating can have an adverse effect on processing speed. The LockOperationUpdates command disables immediate updating. Once all operation changes are complete, updating can be enabled and a single Update performed.
For i=22 To 3200 : 'change some parameter values for these 3178 nodes : : For i=22 To 3200 Update
"(Re)Start" coordinate system Use the StartCoordSys command to change the reference coordinate system for an entity. Here, the reference coordinate system for "Mirror1" is changed to the be Global coordinate system (-1).
id=FindName("Mirror1")
The RestartCoordSys command changes the entity reference coordinate system AND deletes all operations on that entity. In this example, the GetCoordSys command is used to determine the desired coordinate system identifier before proceeding with the change.
pid=FindName("Prism") n=GetCoordSys(pid) mid=FindName("Mirror1") RestartCoordSys(mid,n)
"Place/Rotate/Shift" operations The Place/Rotate/Shift commands provide a convenient alternative to AddOperation for the purpose of repositioning/reorienting entities. Note, however, that these commands require a coordinate system as one of their arguments.
As an example, these lines of code add a "ShiftZ" operation to lens element Edmund 31859. This shift is done with respect to the back surface of the Edmund 43399 element. To complete this task, first determine the identifiers of the Edmund 43399 back surface entity and the Edmund 31859 element. Next, issue the ShiftZ command and Update the FRED document.
l1id=FindFullName("Geometry.Edmund 43399 # 1.Surface 2") ShiftZ l2id, l1id, 1.208
"Transform" a vector Use the "Transform" commands to compute the direction of a vector in one coordinate system as expressed in another coordinate system.
In this example, "Mirror1" local z-direction faces in the global y-direction while "Mirror2" local z-direction faces in the global z-direction. Given a vector (0,0,1) expressed in the local coordinate system of "Mirror1", that same vector expressed in the local coordinate system of "Mirror2" is (0,1,0). id1=FindFullName("Mirror1")
Output Window says: 0 0 1 0 1 0
See Also….
|