Cancel
Showing results for 
Search instead for 
Did you mean: 

User Defined Objects(UDO) in NXOpen

Pioneer
Pioneer

Hi All,

Can ayone help me to create a UDO to store mutidimensional arrays. I am able to store one dimensional arrays in UDO but not muti dimensional.

 

Thanks

5 REPLIES

Re: User Defined Objects(UDO) in NXOpen

Siemens Phenom Siemens Phenom
Siemens Phenom

It seems the calls currently available both in Open C and the Common API only work with one-dimensional arrays of doubles.  You can submit an ER to ask for this functionality in some future release of the software, 

Re: User Defined Objects(UDO) in NXOpen

Pioneer
Pioneer

Thank you!!!!

 

I am trying to store number of string array in one udo object but I have seen that if I access that number of string array using (displayEvent.UserDefinedObject.GetStrings), it will give me only the last array.

 

Is there any way to store array by name so I can access the array by name from the udo object.

Re: User Defined Objects(UDO) in NXOpen

Phenom
Phenom

UDOs only have tha capacity to store 1 array of integers, 1 array of doubles, 1 array of strings etc.

There are 2 ways to store more complicated data structures:

 

Use multiple UDO instances:

  1. Have a main UDO instance that holds an array of strings that are names of arrays that you would like to access
  2. Have another UDO instance for each of the members of the array in the main UDO
  3. Create an object link between the main UDO and the other UDOs
  4. To access a given array member look it up in the main UDO string array to get it's index, navigate to the linked UDO by using the index in the links array, then read the string from the other UDO
  5. Beware when using this method that if any of the UDOs that hold the data get deletedthe string array in the main UDO will not automatically get updated. Things can get very corrupt very quickly.

 

Simulate sub-arrays in the string array:

  1. When you store the data, format a string to represent each string array, for instance "{A,B,C,D}"
  2. Store each formatted 'array' into the UDOs string array, so the UDO string array would hold:
    "{A,B,C,D}" , "{ME,YOU,US}" , "{SOME,OTHER,DATA}"
  3. When reading the data, parse the formatted array to extract the data

 

I've used both of these in the past. Hope that helps.

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | KF
Production: NX8.5.3.3 MP11 64bit Testing: NX9.0.2.5

Re: User Defined Objects(UDO) in NXOpen

Solution Partner Experimenter Solution Partner Experimenter
Solution Partner Experimenter

I am getting an "exception" -- "You do not have permission to query this class id."

when trying to access the saved UDO.

 

Exception is thrown at call

"theSession.UserDefinedClassManager.GetUserDefinedClassFromClassName("MYUDO")"

 

This only happens when its a new NXSession (UI is closed and re-opened), in the same session when document is closed and re-opened the exception is not thrown and I am able to access the saved UDO.

 

"AllowQueryClassForName" is also "ON" during save.

udoclass.AllowQueryClassFromName = UserDefinedClass.AllowQueryClass.On;

Re: User Defined Objects(UDO) in NXOpen

Siemens Phenom Siemens Phenom
Siemens Phenom

You can always use a 1D array of length M*N in place of a 2D array with dimensions M x N. In fact, that's what most programming languages do internally -- the double indexing is just syntactic sugar.

 

So, the two statements

 

x = array2d(i,j)
x = array1d(m*i + j)

are equivalent. The first one is much easier to read/understand, but the second one really indicates what's happening internally.

 

Another idea: have you tried using the new Custom Feature capability, rather than a UDO. Newer doesn't necessarily mean better, but sometimes it does.

山田
yamada