Showing results for 
Search instead for 
Do you mean 
Solved! Go to solution

scale dumb curves

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...


Re: scale dumb curves

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.

Accepted by topic author cowski1
‎08-26-2015 04:32 AM

Re: scale dumb curves

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.


    /// <summary>
   /// This function will scale given NX Objects
   /// </summary>
    /// <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[3];
        double[] scaleMatrix = new double[16];
        int status;

        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];
        Tag trace_curve_group;
        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);


Re: scale dumb curves

Thanks, that's what I needed.

Re: scale dumb curves


When I convert the above code to VB, I get this error,

can anyone help me please.

Re: scale dumb curves

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).

Re: scale dumb curves

Thanks it worked.


Re: scale dumb curves

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

Re: scale dumb curves

If you have access to SNAP, then Snap.Geom.Transform.CreateScale will also do the job. As always, see the Reference Guide for details and examples.