Hello,
Someone has the knowledges to convert this code into VB .net?
From: https://solutions.industrysoftware.automation.siemens.com/view.php?sort=...
Regards!
using System;
using NXOpen;
using NXOpen.UF;
using NXOpen.Routing;
using NXOpen.UserDefinedObjects;
using System.Collections.Generic;
using NXOpen.Utilities;
public class UDOLister
{
//--------------------------------------------------------------------------------------------------
public static int Main(string[] args)
{
try
{
Session theSession = Session.GetSession();
ListingWindow listingWindow = theSession.ListingWindow;
if (!listingWindow.IsOpen)
listingWindow.Open();
List userDefinedObjects = new List();
userDefinedObjects = FindAllUserDefinedObjects(theSession.Parts.Work);
Echo("Found " + userDefinedObjects.Count.ToString() + " User Defined Objects.");
foreach (UserDefinedObject userDefinedObject in userDefinedObjects)
{
Echo("");
Echo("---------------------------------------------------");
Echo("Class Name : " + userDefinedObject.ClassName);
Echo("Tag : " + userDefinedObject.Tag.ToString());
int[] integers = userDefinedObject.GetIntegers();
Echo("Number of integer values : " + integers.Length.ToString());
foreach (int integer in integers)
Echo(" " + integer.ToString());
double[] doubles = userDefinedObject.GetDoubles();
Echo("Number of double values : " + doubles.Length.ToString());
foreach (double doubleValue in doubles)
Echo(" " + doubleValue.ToString());
string[] strings = userDefinedObject.GetStrings();
Echo("Number of string values : " + strings.Length.ToString());
foreach (string stringValue in strings)
Echo(" \"" + stringValue + "\"");
double[] areas = userDefinedObject.GetAreas();
Echo("Number of area values : " + areas.Length.ToString());
foreach (double area in areas)
Echo(" " + area.ToString());
double[] volumes = userDefinedObject.GetVolumes();
Echo("Number of volume values : " + volumes.Length.ToString());
foreach (double volume in volumes)
Echo(" " + volumes.ToString());
UserDefinedObject.LinkDefinition[] links =
userDefinedObject.GetLinks(UserDefinedObject.LinkType.Owning);
Echo("Number of owning links : " + links.Length.ToString());
foreach (UserDefinedObject.LinkDefinition link in links)
Echo(" " + link.ToString());
links = userDefinedObject.GetLinks(UserDefinedObject.LinkType.Type1);
Echo("Number of Type1 links : " + links.Length.ToString());
foreach (UserDefinedObject.LinkDefinition link in links)
Echo(" " + link.ToString());
links = userDefinedObject.GetLinks(UserDefinedObject.LinkType.Type2);
Echo("Number of Type2 links : " + links.Length.ToString());
foreach (UserDefinedObject.LinkDefinition link in links)
Echo(" " + link.ToString());
links = userDefinedObject.GetLinks(UserDefinedObject.LinkType.Type3);
Echo("Number of Type3 links : " + links.Length.ToString());
foreach (UserDefinedObject.LinkDefinition link in links)
Echo(" " + link.ToString());
NXObject.AttributeInformation[] attributes = userDefinedObject.GetUserAttributes();
Echo("Number of user attributes : " + attributes.Length.ToString());
foreach (NXObject.AttributeInformation attribute in attributes)
{
string formattedOutput = String.Format("{0,-25} = {1}", attribute.Title, attribute.StringValue);
Echo(" " + formattedOutput);
}
}
}
catch (NXException ex)
{
UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
}
catch (Exception ex)
{
UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
}
return 0;
}
//--------------------------------------------------------------------------------------------------
// Creates a list of all the User Defined Objects in the given part.
private static List FindAllUserDefinedObjects(Part workPart)
{
UFSession ufSession = UFSession.GetUFSession();
List userDefinedObjects = new List();
Tag udoTag = Tag.Null;
do
{
ufSession.Obj.CycleObjsInPart1(workPart.Tag, UFConstants.UF_user_defined_object_type, ref udoTag);
if (udoTag == Tag.Null)
break;
UserDefinedObject userDefinedObject = (UserDefinedObject)NXObjectManager.Get(udoTag);
userDefinedObjects.Add(userDefinedObject);
} while (udoTag != Tag.Null);
return userDefinedObjects;
}
public static void Echo(string output)
{
Session theSession = Session.GetSession();
theSession.ListingWindow.Open();
theSession.ListingWindow.WriteLine(output);
theSession.LogFile.WriteLine(output);
}
//--------------------------------------------------------------------------------------------------
public static int GetUnloadOption(string arg)
{
// Unloads the image immediately after execution within NX
return System.Convert.ToInt32(Session.LibraryUnloadOption.Immediately);
}
}
It's ok..
I used this site and everything works ... with some minor changes.
http://converter.telerik.com/
Regards!
Pat