HI Ronald,
I tried to search for it on GTAC site, I found a VB sample code and Open C API sample program. VB sample code, didnt work. Iam not sure how to use Open C API code. Here is the Open C API code .
/*HEAD DELETE_ALL_OBJECTS_ON_LAYER CCC UFUN */
#include <stdio.h>
#include <string.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_layer.h>
#include <uf_obj.h>
#include <uf_modl.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 void set_layer_active(int layer)
{
UF_CALL(UF_LAYER_set_status(layer, UF_LAYER_ACTIVE_LAYER));
}
static int allocate_memory(unsigned int nbytes, void **where)
{
int
resp;
*where = UF_allocate_memory(nbytes, &resp);
return resp;
}
static int make_an_array(uf_list_p_t *object_list, tag_t **objects)
{
int
ii,
n;
uf_list_p_t
temp;
UF_CALL(UF_MODL_ask_list_count(*object_list, &n));
UF_CALL(allocate_memory(n * sizeof(tag_t), (void **)objects));
for (ii = 0, temp = *object_list; ii < n; temp = temp->next, ii++)
(*objects)[ii] = temp->eid;
UF_CALL(UF_MODL_delete_list(object_list));
return n;
}
static int ask_all_objects_on_layer(int layer, tag_t **objects)
{
tag_t
object = NULL_TAG;
uf_list_p_t
list;
UF_CALL(UF_MODL_create_list(&list));
while (!UF_CALL(UF_LAYER_cycle_by_layer(layer, &object)) &&
(object != NULL_TAG)) UF_CALL(UF_MODL_put_list_item(list, object));
return make_an_array(&list, objects);
}
#ifndef UF_LAYER_MAX_LAYER
#define UF_LAYER_MAX_LAYER 256
#endif
static logical prompt_for_a_layer(char *prompt, char *item, int *number)
{
int
irc,
resp;
char
laymsg[100],
menu[1][16];
int
da[1];
strcpy(&menu[0][0], item);
da[0] = *number;
resp = uc1607(prompt, menu, 1, da, &irc);
if (resp == 3 || resp == 4)
{
*number = da[0];
if ((*number > UF_LAYER_MAX_LAYER) || (*number <= 0))
{
sprintf(laymsg, "Layers range from 1 to %d", UF_LAYER_MAX_LAYER);
uc1601(laymsg, TRUE);
return prompt_for_a_layer(prompt, item, number);
}
return TRUE;
}
else return FALSE;
}
static void do_it(void)
{
int
layer = 1,
n_objs;
tag_t
*objs;
char
messg[133];
while (prompt_for_a_layer("Delete objects from", "Layer", &layer))
{
set_layer_active(layer);
n_objs = ask_all_objects_on_layer(layer, &objs);
if (n_objs > 0)
{
UF_CALL(UF_OBJ_delete_array_of_objects(n_objs, objs, NULL));
UF_free(objs);
}
else
{
sprintf(messg, "\nNo objects found on layer %d",layer);
uc1601(messg,1);
}
}
}
/*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);
}