Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Trying to move a UF_MODL_create_scale with UF_MODL_move_feature using C

Experimenter
Experimenter

The issue is with scaling an object using UF_MODL_create_scale and then trying to rotate the object using UF_MODL_move_feature.

The problem outlined below is a simplification of a much more complicated problem.

First a cylinder is created along the z axis and then scaled using the UF_MODL_create_scale function with scale type UF_SCALE_TYPE_GENERAL using a coordinate system at the centre of the cylinder and a scale factor along the y axis.

The cylinder is then rotated by using UF_MODL_move_feature using the option CSYS_TO_CSYS however when this is executed, the cylinder has rotated but the scale has not, and the following error is produced: ERROR code 670278 Cannot move feature.

Is it possible to be able to rotate the scale? Is UF_MODL_move_feature the right function to use for this?

//Cylinder Creation Declarations
char *diameter = "5";
char *height = "8";
tag_t cyl_feature_tag = NULL_TAG;
tag_t cyl_body_tag = NULL_TAG;

//Scaling Declarations
int count = 0;
int num_body_tags = 1;
char factors_2[3][UF_MAX_EXP_BUFSIZE] = { "2", "1", "1" };
tag_t so_point = NULL_TAG;
tag_t so_dir = NULL_TAG;
tag_t *tags = NULL;

//Matrix Declarations
double zvector[3] = { 0.0, 0.0, 1.0 };
double matrix_values[9] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
tag_t matrix_id = NULL_TAG;
double local[3] = { 0.0, 0.0, 0.0 };
tag_t csys_id = NULL_TAG;

//Rotation Declarations
uf_list_p_t rot_feature_list;
double rot_move_data[2][12] = { { 0, 0, 4, 1, 0, 0, 0, 1, 0, 0, 0, 1 }, { 0, 0, 0, 0, 0, 1, 0, 1, 0, -1, 0, 0 } };

//Matrix creation
UF_MTX3_initialize_z(zvector, matrix_values);
UF_CSYS_create_matrix(matrix_values, &matrix_id);
UF_CSYS_create_temp_csys(local, matrix_id, &csys_id);

//Create and scale cylinder
UF_MODL_create_cyl1(UF_NULLSIGN, local, height, diameter, zvector, &cyl_feature_tag);
UF_MODL_ask_feat_body(cyl_feature_tag, &cyl_body_tag);
UF_MODL_create_scale(UF_SCALE_TYPE_GENERAL, &cyl_body_tag, num_body_tags, so_point, so_dir, csys_id, factors_2, &tags);
UF_free(tags);

//Rotate
UF_CALL(UF_MODL_ask_body_feats(cyl_body_tag, &rot_feature_list));
UF_CALL(UF_MODL_move_feature(rot_feature_list, 2, rot_move_data));
UF_CALL(UF_MODL_update());
UF_CALL(UF_MODL_set_update_fail_option(UF_MODL_UPDATE_ACCEPT));

 

5 REPLIES 5

Re: Trying to move a UF_MODL_create_scale with UF_MODL_move_feature using C

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Guessing...

You are moving the body of the original cylinder.

Not the body of the scale feature.

You need to use the tag(s) returned by UF_MODL_create_scale to find the bodiy/bodies of the scale feature(s) and rotate THOSE bodies.

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP16/TC11.2
I'd rather be e-steamed than e-diseaseled


Re: Trying to move a UF_MODL_create_scale with UF_MODL_move_feature using C

Siemens Phenom Siemens Phenom
Siemens Phenom

If I select Edit -> Feature -> Move, NX will only allow me to select non-associative features - I cannot pick the scale body.

 

If I select Edit -> Move Object, I can pick the scale body, and although it only shows one object selected, the cylinder feature also lights up in the part navigator.  But it does allow me to perform the move.  Record a journal while you do that to see what the code would look like.  (Hint:  It won't look like user function!)

Re: Trying to move a UF_MODL_create_scale with UF_MODL_move_feature using C

Experimenter
Experimenter

Thank you for the reply. 

 

The UF_MODL_ask_body_feats uses the tag for the scale feature and passes this into UF_MODL_move_feature which is what causes the error. When I use the tag for the scale the same error appears.

Re: Trying to move a UF_MODL_create_scale with UF_MODL_move_feature using C

Experimenter
Experimenter

I have tried this in the user interface also and tried journaling it but as journals do not support C, I haven't had much luck. I've tried looking through the functions to find the equivalent function in C but it doesn't look like there is one.

Re: Trying to move a UF_MODL_create_scale with UF_MODL_move_feature using C

Siemens Phenom Siemens Phenom
Siemens Phenom

The good news is that you can record journals in C++, and you can use the NX Open C++ code in the same source file as your traditional Open C.  Three main things to remember:

 

1) You will have to call both UF_initialize() and GetSession().

 

2) You will have to include the appropriate headers from both the ugopen folder and the NXOpen folder for any calls that you are using from either kit.

 

3) You will have to rename your program source file to end in .cpp or .cxx.

 

Besides those three things, some people experience a little friction moving back and forth between objects and tags.  If you alread have the object, it will usually have a Tag property, so that way is simple.  To get the object from the tag, you have to call NXObjectManager::Get(yourTag), and you have to be sure you are trying to assign it to the right kind of object.  We have many examples (close to a hundred) that demonstrate mixing these two toolkits in the Solution Center.  Be sure to include the word "interop" as one of your search terms.