Showing results for 
Search instead for 
Do you mean 
Reply

Block Styler UI ListBox of Parents C#

Hi All Smiley Happy 

i need some Help with my c# code and hope that sombody could help me Smiley Happy

 

I want to create  a UI with the Block Styler.

The idea is to select multiple Curves (Splines) and then list their Parents (Features) automatically by pressing an Action Button in a ListBox.

 

1. Which Function could i use to select all Parents of the Spline. I tried with AskObjectFeature(), but the method is only to get one Feature:/ Is there any alternative ?

2.How do i list for example all selected Curves (or their Parents) from the Curve Selector in a List Box ? Is there a Function which i could use ? Because all the Methods i would use are protected Internal :/

3. i created a Tagged Object where i saved all selected Curves from the Curve Selector. Is there a posibility to get the Strings (Names) of the Curves in the Tagged Object ? i tried with .toString but i always get an error message.

 

thanks for every answer Smiley Happy

 

 

10 REPLIES

Re: Block Styler UI ListBox of Parents C#

Try using 'UF_SO_ask_parents(...) function to get the parent objects.

 

You can populate the list box by the tags.  Use curve.tag.toString method.  If the curves have names use taggedobject.name method.

Re: Block Styler UI ListBox of Parents C#

[ Edited ]

Hi Technisites,

thanks for your answer and help.

 

Get Parents objects :

I have some Problems with the AskParents Method.

What is the meaning of the int options in the Declaration Sytax.

When i use the AskParents Method i get a Null Reference Exception. I think because of the wrong usage of the int Options.

could you give me an example for the int option ?

 

Re: Block Styler UI ListBox of Parents C#

There is an example on the solution center.  Below is the link.

 

https://solutions.industrysoftware.automation.siemens.com/view.php?sort=desc&q=parent+object&dt=nx-a...

 

Re: Block Styler UI ListBox of Parents C#

i always get a NullReferenceException. but why ?

Tag[] parents = new Tag[100];
int n_parents;
allSelectedFeatures = edge_select0.GetSelectedObjects();
Ask_Parents.AskParents(allSelectedFeatures[0].Tag, NXOpen.UF.UFConstants.UF_SO_ASK_ALL_PARENTS, out n_parents, out parents);

Re: Block Styler UI ListBox of Parents C#

Make sure you are not passing in a null tag.  

Re: Block Styler UI ListBox of Parents C#

The Debugger Shows that allSelectedFeatures[0] gets a Tag. :/ Its a Number.

Re: Block Styler UI ListBox of Parents C#

But my Ask_Parents is null ? Why ?
public NXOpen.UF.UFSo Ask_Parents;

Re: Block Styler UI ListBox of Parents C#

May be this will work.



using System;

using NXOpen;

using NXOpen.UF;







class Ask_Parents

{

static Session s = Session.GetSession();

static UFSession ufs = UFSession.GetUFSession();

static ListingWindow lw = s.ListingWindow;



public static void Main()

{



NXObject theObj = null;



theObj = select_obj("Select Edge");

if (theObj.Tag != Tag.Null)

{

int num_parents=0;

int num_children = 0;

Tag[] pareant_feat_tags;

Tag[] child_feat_tags;

Tag[] parent_Tags;



ufs.Disp.SetHighlight(theObj.Tag, 0);



ufs.Modl.AskEdgeFeats(theObj.Tag, out parent_Tags);





for (int i=0; i
{

lw.Open();

lw.WriteLine("Tag is " + parent_Tags[i].ToString());



ufs.Modl.AskFeatRelatives(parent_Tags[i], out
num_parents, out pareant_feat_tags,

out num_children, out child_feat_tags);



lw.WriteLine("Found " + num_parents.ToString() + "
parent features and "

+ num_children.ToString() + " child features");



for (int j = 0; j < num_parents; j++)

lw.WriteLine("Parent Feat tag is " + parent_Tags[j].
ToString());

}

}



}







private static NXObject select_obj(string prompt)

{

UI theUI = UI.GetUI();

NXObject selobj;

Point3d cursor;

Selection.MaskTriple[] mask = new Selection.MaskTriple[1];



mask[0].Type = UFConstants.UF_solid_type;

mask[0].Subtype = UFConstants.UF_solid_body_subtype;

mask[0].SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_EDGE;





Selection.Response resp = theUI.SelectionManager.SelectObject("Select
"+prompt, prompt,

Selection.SelectionScope.WorkPart, Selection.SelectionAction.
ClearAndEnableSpecific, false, true, mask, out selobj, out cursor);



if (resp == Selection.Response.ObjectSelected ||

resp == Selection.Response.ObjectSelectedByName)

{

return selobj;

}

else

return null;



}







}







Suresh

Re: Block Styler UI ListBox of Parents C#

[ Edited ]

Wow thank you very very much for your help !!
i'll try it !