Hallo an die Profis!
ich möchte meine Nativ-Umgebung auffrisieren und neue Parts gerne automatisch ohne Zusatzprogramme auf Basis eines Seedparts erstellen. Dazu gibt es in NX-Open Samples einen Quellcode, der aber noch mit einem C-Compiler compiliert werden muss. Ich hab kein Problem mit VisualBasic.net zu programmieren und zu compilieren, doch für C hab ich nun überhaupt keinen Plan ;-)....
Außerdem finde ich den Compiler ufcomp, wie er in der Hilfe beschrieben wird, nicht in den Installationen.
Die Ergänzung der Anwendungsumgebung wäre in 3 Schritten zu machen, was aus dem Open-Sample ja auch klar hervorgeht:
1. .men-Datei erstellen,
2. Umgebungsvariable setzen, Zitat:
/* This program demonstrates using a seed part when creating new
components. To replace the standard UG action taken when the user
selects Assemblies->Components->Create New... with this program, save
the menuscript file lines below to a file using a ".men" extension in a
"startup" subdirectory of a directory listed in either
$UGII_UG_CUSTOM_DIRECTORY_FILE or $UGII_CUSTOM_DIRECTORY_FILE. E.g.
$UGII_USER_DIR/startup
3. C-Quellcode compilieren ... ????
Das Menufile und Umgebungsvariable sind ja klar, sind ja auch vollständig vorhanden:
! Begin menufile
VERSION 120
EDIT UG_GATEWAY_MAIN_MENUBAR
MODIFY
BUTTON UG_ASSY_INSERT_NEW_COMPONENT
ACTIONS create_component_using_seed_part
END_OF_MODIFY
! End menufile
Aber wie compiliere und signiere ich jetzt das Programm (möglichst für "lau")(hab einfach zu wenig Ahnung um dies in VB.NET umzuschreiben):
*/
#include <stdio.h>
#include <string.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_obj.h>
#include <uf_part.h>
#include <uf_cfi.h>
#include <uf_assem.h>
#define UF_CALL(X) (report_error( __FILE__, __LINE__, #X, (X)))
static int report_error( char *file, int line, char *call, int irc)
{
if (irc)
{
char err[133],
msg[133];
sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
irc, line, file);
UF_get_fail_message(irc, err);
/* NOTE: UF_print_syslog is new in V18 */
UF_print_syslog(msg, FALSE);
UF_print_syslog(err, FALSE);
UF_print_syslog("\n", FALSE);
UF_print_syslog(call, FALSE);
UF_print_syslog(";\n", FALSE);
if (!UF_UI_open_listing_window())
{
UF_UI_write_listing_window(msg);
UF_UI_write_listing_window(err);
UF_UI_write_listing_window("\n");
UF_UI_write_listing_window(call);
UF_UI_write_listing_window(";\n");
}
}
return(irc);
}
static logical is_file_there(char *file_spec)
{
int missing = TRUE;
UF_CALL(UF_CFI_ask_file_exist(file_spec, &missing));
if (missing)
return FALSE;
else
return TRUE;
}
static void combine_directory_and_wildcard(char *dir, char *fltr, char *spec)
{
if (!strcmp(dir, ""))
strcpy(spec, fltr);
else
{
UF_CALL(uc4575(dir, 0, "junk.xxx", spec));
strcpy(strstr(spec, "junk.xxx"), fltr);
}
}
static logical prompt_for_new_part_name(char *prompt, char *fspec)
{
int
resp;
char
filter[UF_CFI_MAX_PATH_NAME_SIZE],
*p_dir,
*p_ext;
UF_CALL(UF_UI_ask_dialog_directory(UF_UI_PART_DIR, &p_dir));
UF_CALL(UF_UI_ask_dialog_filter(UF_UI_PART_OPEN_FLTR, &p_ext));
combine_directory_and_wildcard(p_dir, p_ext, filter);
UF_free(p_dir);
UF_free(p_ext);
while (!UF_CALL(UF_UI_create_filebox(prompt, "Part Name", filter, "",
fspec, &resp)) && (resp != UF_UI_CANCEL))
{
if (!is_file_there(fspec)) return TRUE;
uc1601("File exists - try again", TRUE);
}
return FALSE;
}
static void report_load_status(UF_PART_load_status_p_t status)
{
char
msg[133];
int
ii;
if (status->n_parts > 0)
{
UF_UI_open_listing_window();
UF_UI_write_listing_window("Load notes:\n");
for (ii = 0; ii < status->n_parts; ii++)
{
UF_UI_write_listing_window(" ");
UF_UI_write_listing_window(status->file_names[ii]);
UF_UI_write_listing_window(" - ");
UF_get_fail_message(status->statuses[ii], msg);
UF_UI_write_listing_window(msg);
UF_UI_write_listing_window("\n");
}
UF_UI_write_listing_window("\n");
UF_free(status->statuses);
UF_free_string_array(status->n_parts, status->file_names);
}
}
static int select_objects(char *prompt, tag_t **objects)
{
int
cnt,
ii,
resp;
UF_CALL(UF_UI_select_with_class_dialog("Select Objects", prompt,
UF_UI_SEL_SCOPE_WORK_PART, NULL, NULL, &resp, &cnt, objects));
for (ii = 0; ii < cnt; ii++)
UF_CALL(UF_DISP_set_highlight((*objects)[ii], 0));
return cnt;
}
static void do_it(void)
{
int
n_objects;
tag_t
cpart,
instance,
*objects,
wpart = UF_ASSEM_ask_work_part();
double
abs[6] = { 1,0,0, 0,1,0 },
zero[3] = { 0,0,0 };
char
cspec[UF_CFI_MAX_PATH_NAME_SIZE] = { "" };
UF_PART_load_status_t
error_status;
UF_PART_export_options_t
opts = { FALSE, UF_PART_maintain_all_params,
UF_PART_copy_exp_shallowly };
n_objects = select_objects("Select objects for new component", &objects);
if (!prompt_for_new_part_name("Create component", cspec)) return;
UF_CALL(UF_PART_open_quiet("parts/seed.prt", &cpart, &error_status));
if (error_status.n_parts > 0) report_load_status(&error_status);
if (error_status.failed) return;
UF_CALL(UF_PART_rename(cpart, cspec));
if (n_objects > 0)
{
UF_CALL(UF_PART_export_with_options(cspec, n_objects, objects, &opts));
UF_CALL(UF_OBJ_delete_array_of_objects(n_objects, objects, NULL));
UF_free(objects);
}
UF_CALL(UF_ASSEM_add_part_to_assembly(wpart, cspec, "", "", zero, abs,
-1, &instance, &error_status));
if (error_status.n_parts > 0) report_load_status(&error_status);
}
/*ARGSUSED*/
void ufusr(char *param, int *retcode, int paramLen)
{
if (UF_CALL(UF_initialize())) return;
do_it();
UF_terminate();
}
int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
}
Danke für eine Anleitung!
mfg
Konrad
Eine Antwort auf diesen Beitrag verfassen (mit Zitat/Zitat des Beitrags) IP