Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NX1899: Deleting ghost entities reported in layers of part / assembly file

Status
Not open for further replies.
Jan 24, 2020
80
0
0
US
Hi All,

I was wondering if anyone has come across or developed a tool to find the ghost entities and help delete them. Many times it is seen that entities are reported on layers which are some cached or something.
 
Replies continue below

Recommended for you

Hi Jerry,

Thats not clearing up 100%. Sometimes we run it multiple times and still see entities on layers . Now We make those layers work layer and hide all other layer. Make sure everything is shown and delete them . Still NX says there are few entities which are on that layer in Modeling and drafting . So we call them Ghost Entities.
 
In the layer settings dialog, there is an information command that will generate a report of object types on layers.

In my experience, groups often confuse users. A group object shows up in the layer count of objects, even though the group object itself doesn't have a graphical representation on screen.

www.nxjournaling.com
 
I know there is a function created by the developers to delete EVERYTHING on a layer.
If I remember correctly it was created (originally) in grip, but there should be an NXOpen version available as well.
Unfortunately, due to a password issue, I have no access to the GTAC knowledge base at the moment.

If you have access to that web page you (or maybe someone else on this forum) can search for "Delete all on Layer"

You have to be careful using this, as it will delete everything on the layer entered (also these ghost entities) without confirmation.

Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2

Building new PLM environment from Scratch using NX12 / TC11
 
I cannot say i have this issue.
as Cowski says, use the Layer settings-information button to see what type of objects you have on the layer, then check if that is to be deleted or not.
there is a group "folder" in the part navigator which can be used to select groups, also non- timestamp curves will be selectable there.
if the curves are from a .dxf / dwg import, that often brings "view dependent geometry" ( lines arcs etc) Try replacing the view ( not Orienting) to see the #Active1 -view
Regards,
Tomas

 
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);
}
 
CAD Application Support said:
I am not sure how to use Open C API code.
If you have an NXOpen C author license and a compatible compiler, you can compile the code and run it in NX. Otherwise, there isn't much you can do with it.

What did the layer dialog report tell you, what type of objects are on the layer?
Can you provide a link to the VB code?

www.nxjournaling.com
 
Hi All,

I copy pasted the below code in Menu >> Journal >> Edit . I gave a name to the file and saved it. Then played the journal, it worked well.. Thanks all for helping and inputs on this.

Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI

Module delete_all_objects_on_specified_layer

Public theSession As Session = Session.GetSession()
Public theUFSession As UFSession = UFSession.GetUFSession()

Sub Main()

Dim layerNum As Integer = 0
Dim userInputNumber As Double

userInputNumber = NXInputBox.GetInputNumber("Layer to wipe clean:")
layerNum = userInputNumber

If layerNum < 1 Or layerNum > 256 Then
MsgBox("That is not a valid layer.", MsgBoxStyle.Information)
Return
End If

Dim dispPart As Part = theSession.Parts.Display

Dim objs() As NXObject = dispPart.Layers.GetAllObjectsOnLayer(layerNum)

Dim toDelete As System.Collections.ArrayList = New System.Collections.ArrayList

For Each obj As NXObject In objs

Dim theType As Integer
Dim theSubtype As Integer

theUFSession.Obj.AskTypeAndSubtype(obj.Tag, theType, theSubtype)
If (Not theType = UFConstants.UF_parametric_text_type) And
((Not theType = UFConstants.UF_tabular_note_type) Or _
(theSubtype = UFConstants.UF_tabular_note_section_subtype)) Then
toDelete.Add(obj)
End If

Next

theSession.Information.DisplayObjectsDetails(toDelete.ToArray(GetType(NXObject)))

If AskYesOrNo("Check Information Listing", "Delete all of these objects?") Then
Dim undoMark As Session.UndoMarkId =
theSession.SetUndoMark(Session.MarkVisibility.Visible,
"Delete objects on layer " & layerNum)
theSession.UpdateManager.AddToDeleteList(toDelete.ToArray(GetType(NXObject)))
theSession.UpdateManager.DoUpdate(undoMark)
End If

End Sub

Function AskYesOrNo(ByVal title As String, ByVal message As String) As Boolean
Dim messages As String() = {message}
Dim buttons As UFUi.MessageButtons
With buttons
.button1 = True
.button2 = False
.button3 = True
.label1 = "Yes"
.label2 = Nothing
.label3 = "No"
.response1 = 1
.response2 = 0
.response3 = 2
End With
Dim resp As Integer

theUFSession.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
theUFSession.Ui.MessageDialog(title, UiMessageDialogType.UiMessageQuestion, messages, 1, True, buttons, resp)
theUFSession.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)

If resp = 1 Then Return True Else Return False
End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer
Return Session.LibraryUnloadOption.Immediately
End Function

End Module
 
Status
Not open for further replies.
Back
Top