Showing results for 
Search instead for 
Did you mean: 

UF_UDOBJ_ask_class_id_of_name doesn't work

Valued Contributor
Valued Contributor

I have a repeatable case where the following occurs (I'm using NX 9, vuilding under Visual Studio 2012 Update 1).  Upon executing the following two lines:


UF_UDOBJ_create_class(className.c_str(), friendlyName.c_str(), &classid);
UF_UDOBJ_ask_class_id_of_name(className.c_str(), &classid);


When the first line succeeds, setting a nonzero value in classid, the second line fails for some reason, setting the value of classid to zero.  The second line is executed immediately after the first, so no funny business occurs in between.  Also, className and friendlyName are non-empty strings containing only letters, numbers, spaces, and underscores.  So it seems to me that this is a bug -- UF_UDOBJ_ask_class_id_of_name should not fail here.


The reason we are executing these lines back-to-back like this is we want to load the class with that name if it exists, and otherwise we want to create it. If a class already exists with the chosen name, the first line will fail, but the second line will find the id.  Whereas if no class exists with that name, the first line will succeed and the second line should simply find the same id that the first line reserved.  Unfortunately, this is not working because of this bug.


In the meantime, we are using the following:
UF_UDOBJ_ask_class_id_of_name(className.c_str(), &umuClass);
if(0 == umuClass)
    UF_UDOBJ_create_class(className.c_str(), friendlyName.c_str(), &umuClass);


However, I am not confident that UF_UDOBJ_ask_class_id_of_name is working at all, even in the above snippet.


Re: UF_UDOBJ_ask_class_id_of_name doesn't work

Siemens Phenom Siemens Phenom
Siemens Phenom


This should help if you call it in between your two lines of code:



UF_UDOBJ_set_query_class_id ()

Defined in: uf_udobj.h
Set the behavior of querying the class id given the class name. The default
mode is UF_UDOBJ_DONT_ALLOW_QUERY_CLASS_ID. This means that if you call
UF_UDOBJ_ask_class_id_of_name with the UDO's class name, an error code will be
returned, and the class id returned will be 0. This mechanism is used to
help protect the integrity of a proprietary UDO.

Setting the query to UF_UDOBJ_ALLOW_QUERY_CLASS_ID means that given a class name,
you can find the class id. This mechanism is used to pass the class id
across multiple shared libraries.

Re: UF_UDOBJ_ask_class_id_of_name doesn't work

Valued Contributor
Valued Contributor
Thanks! Obviously, I'm a rank novice here.