I have a file containing only dumb curves (imported dxf file) that I'd like to scale. In interactive NX, I'd use the Edit -> transform -> scale command; is there an equivalent API command?
I've not been able to find one by searching in the NXOpen API reference or the GTAC solution center...
Solved! Go to Solution.
Try UF_MODL_create_uniform_scale or UF_MODL_create_non_uni_scale
These would show up as NXOpen.UF.UFModl.CreateUniformScale and NXOpen.UF.UFModl.CreateNonUniScale in the wrapped API.
UF_MODL_create_uniform_scale or UF_MODL_create_non_uni_scale will not work as it takes body tag as input. Equivalent function for "Transform" can be found in 'UF_TRNS' class. The idea is first you have to get the matrix for your operation (e.g. scaling, rotating, moving etc) and you have to pass that matrix in function "theUfSession.Trns.TransformObjects" to do transformation. Below I have written a small function which will help you to do the same.
/// This function will scale given NX Objects
/// <param name="objects2Scale: are objects to be scaled" ></param>
/// <param name="scaleFactors : is array of scale factors in x,y,z direction"></param>
/// <param name="scaleType: 1- Uniform, 2-Non Uniform"></param>
/// <param name="scaleLayer: layer where transformed objects will be send"></param>
public void scaleObjects(NXObject objects2Scale, double scaleFactors, int scaleType, int scaleLayer)
double scaleOrigin = new double;
double scaleMatrix = new double;
theUfSession.Trns.CreateScalingMatrix(ref scaleType, scaleFactors, scaleOrigin, scaleMatrix, out status);
Tag scaledObjects = new Tag[objects2Scale.Length];
for (int p = 0; p < scaledObjects.Length; p++)
scaledObjects[p] = objects2Scale[p].Tag;
int n_scaledObjects = scaledObjects.Length;
int move_or_copy = 1;
int dest_layer = scaleLayer;
int trace_curves = 2;
Tag scaledCopies = new Tag[scaledObjects.Length];
theUfSession.Trns.TransformObjects(scaleMatrix, scaledObjects, ref n_scaledObjects, ref move_or_copy, ref dest_layer, ref trace_curves, scaledCopies, out trace_curve_group, out status);
The definition of the scale matrix needs to look something like this (substitute your variable name in place of "theScaleMatrix").
Dim theScaleMatrix(11) As Double
Arrays are zero based, so this will result in an array with 12 elements (0, 1, 2, ... 11).
CreateScalingMatrix is the wrapper for uf5944. The Open C Reference guide contains a note indicating that the length of the scaling matrix array was changed from 16 to 12:
To fix your VB code, use:
Dim scaleMatrix(12) as Double