Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

Need help on Open API C edit surf code

gergs

New member
Can anyone help me debug the code below. When I compile and run it in NX4 I get an error afterwards when I do an EDIT>FEATURE>PARAMETERS ? Before running it make a simple curve mesh surface. Put a string between primary curves 1 and 2 and name it STRING using EDIT>PROPERTIES. The program will add this string to the surface. Afterwards it gets an error on edit as described above. I have a pic of this surface and error but the upload option here isnt working. Apologies.


Header file "edit_surf_add_string.h" in the code below is a default created by the compiler in MS Vis Studio 6. Nothing in there so I didnt add it.


If you have a working code snippet that shows and edit curve mesh surface to add a sting in NX4 that would help too.


Thanks!!


// ************************************************************ ***************
// Project:edit_surf_add_string
//
// Note: This program adds a string in a mesh surface
// ************************************************************ ***************


// Include Files *************************************************


#include <stdio.h>
#include <uf.h>
#include <uf_ui.h>
#include <stdlib.h>
#include <string.h>
#include <uf_modl.h>
#include <uf_obj.h>
#include <uf_object_types.h>
#include <uf_view.h>
#include <uf_trns.h>
#include <uf_vec.h>


#include "edit_surf_add_string.h"


// Defines *******************************************************


#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))


//Error Report *************************************************


static int report_error( char *file, int line, char *call, int irc)
{
if (irc)
{
char err[133],
msg[133];


UF_get_fail_message(irc, err);


sprintf( msg, "WARNING..................");
uc1601( msg, 1);


sprintf(msg, "ERROR = %s", err);
uc1601( msg, 1);


sprintf(msg, "ERROR code = %d at line %d in %s", irc, line, file);
uc1601( msg, 1);


}
return(irc);
}


//Select a Feature to modify sub function ************************


static tag_t select_a_feature(char *prompt)
{
intcnt= 0,
resp= 0;


tag_tfirst= NULL_TAG,
*feats;

////////////////////////////////////////////////////// /////////


UF_CALL(UF_UI_select_feature(prompt, NULL, &cnt, &feats, &resp));
if (cnt)
{
first = feats[0];
UF_free(feats);
return (first);
}
else return (NULL_TAG);
}


//Main Program ****************************************************


extern DllExport void ufusr( char *parm, int *returnCode, int rlen )
{
intalignment= 0,
body_type= 0,
flags[2]= {0},
patch= 0,
string_set= 0,
vdegree= 0,
vstatus= 0;


charobj_name[133]= "";


doubletol[3]= {0.00},
value[6]= {0.00};


tag_tfaces[2]= {NULL_TAG},
feat= NULL_TAG,
obj_tag= NULL_TAG;


UF_STRING_tnew_string,
section,
spine;


////////////////////////////////////////////////////// /////////


//Start UFUNC, if not bail out
if (UF_CALL(UF_initialize())) return;



// Call feature selection menu
feat = select_a_feature("Select Feature to Modify");


// Get the curve information of the selected feature
UF_CALL(UF_MODL_ask_thru_curves(feat, &section, &spine, &patch,
&a lignment, value, &vdegree, &vstatus,
&b ody_type, tol, faces, flags));



// ADD A NEW STRING


// Initialize a pointer to the new string structure
UF_MODL_init_string_list(&new_string);


// Set the new structure to add 1 section with 1 string
UF_MODL_create_string_list(1, 1, &new_string);


// Get id of new string to add
sprintf( obj_name, "string");
UF_CALL( UF_OBJ_cycle_by_name ( obj_name, &obj_tag ));


// Set structure information for new string to add
new_string.num= 1;
*new_string.string= 1;
*new_string.dir= UF_MODL_CURVE_START_FROM_BEGIN;
new_string.id= &obj_tag;


// Set "string_set" to 1 for primary or to 2 for cross curves
string_set = 1;


// Set what section string to add new string after - string index starts at 1
section.num = 1;


// Add new "string" in - currently hard wired
UF_CALL(UF_MODL_replace_feat_strings(feat, UF_MODL_STRING_ADD,
&new_string, string_set, section.num));


// Update the model
UF_CALL(UF_MODL_update());


// Free lists created for "UF_MODL_ask_thru_curves"
UF_MODL_free_string_list(&section);
UF_MODL_free_string_list(&spine);


UF_CALL(UF_MODL_update());


//Bye
UF_terminate();
}


//Unload **********************************************************


int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
}
 
hi, sorry i cant help you but,


i'am looking for someone who can convert i-deas files to iges


can you help or know someone who can>


thks progmaster
 

Sponsor

Articles From 3DCAD World

Back
Top