cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Using JTree to fill with an assembly

Using JTree to fill with an assembly

Hi!

 

Has anyone ever used a JTree to assemble a structure that is in the Tree View?

 

Note: The picture is just to illustrate.

 

Capturar.PNG

 

Thanks.

6 REPLIES

Re: Using JTree to fill with an assembly

Hi,

it's a little bit of programming but you can do this. I didn't have done that right now but you can read all features with J-Link, and you can programm a tree completly like you want it (also with drag n drop and so on).

I have done both seperately.

Br,

Eike

Re: Using JTree to fill with an assembly

Thanks Eike.

This is just one example, but I'm trying to do this way:


1.PNG

Here I can recover the code and the name of the item, but I can not recover the amount of each item.


I need to do two things from this code:
1) recover the quantity.
2) Insert the information into a JTree.


Thanks.

Re: Using JTree to fill with an assembly

Uh that's not what you want.

You go through all models inside the session. Every model is only one time inside the session.

You need to get the current model.

Check if it is an ASM.

Then you get all Features from these ASM.

Check if it is a Component.

Change Component to Model if it is a part count it inside a Map, tree, whatever

  if it is a asm count it inside a Map / Tree and call the function recursive.

You don't have circles inside of a tree so it never should be a problem.

If the model isn't a component you can ignore it. You also can filter it at the feature list option as far as I remember. But not sure about this.

Br,

Eike

Re: Using JTree to fill with an assembly

The example code is just to try to recover the amount of the item. It is not being recursive nor entering the JTree.

I understand that it is necessary to be recursive when the item is an assembly.


For example:

2.PNG


The result should be this way in the JTree:


84139520 - COMMON NAME- 3


Thanks!

Re: Using JTree to fill with an assembly

Yes you need to be recursive and the addition of standard values could happen inside of a HashTable or whatever ... but that's standard java.

Just count it up ^.^ You'll get 3 Features that all got the samte component inside.

------

Aunt Edit:

So I don't know if it works right with pattern. If not you need to check out if there is a pattern and use the pattern API Commands to find out whats inside.

-------

Br,

Eike

Re: Using JTree to fill with an assembly

is there problems with tree structure?

some codes of my ProToolkit project for reference.

  //init tree

  //node type

  ProUITreeNodeTypeAlloc("typeD",&tntd);

  ProUITreeNodeTypeAlloc("typeE",&tnte);

  ProUITreeNodetypeAdd(XD_ADDNOTEDIALOG_DIALOG,XD_ADDNOTEDIALOG_TREE1,tntd);

  ProUITreeNodetypeAdd(XD_ADDNOTEDIALOG_DIALOG,XD_ADDNOTEDIALOG_TREE1,tnte);

  //root node

  ProTKSprintf(tname,"NodeName0");

  ProTKSwprintf(tlabel,L"RootTitle");

  ProUITreeNodeAdd(XD_ADDNOTEDIALOG_DIALOG,XD_ADDNOTEDIALOG_TREE1,tname,tlabel,NULL,"Default");

  //child node

  num=n_tree;

  j=0;

  k=0;

  for(i=0;i<num;i++)

  {

  if(treelabels[i][0]==L' ')

  {

  k++;

  ProTKSprintf(ttype,"typeE");

  ProTKSprintf(tnamep,"NodeName%d",j);

  ProTKSprintf(tname,"NodeName%d-%d",j,k);

  ProWstringCopy(treelabels[i]+1,tlabel,PRO_VALUE_UNUSED);

  }

  else

  {

  j++;

  k=0;

  ProTKSprintf(ttype,"typeD");

  ProTKSprintf(tnamep,"NodeName0");

  ProTKSprintf(tname,"NodeName%d",j);

  ProWstringCopy(treelabels[i],tlabel,PRO_VALUE_UNUSED);

  }

  ProUITreeNodeAdd(XD_ADDNOTEDIALOG_DIALOG,XD_ADDNOTEDIALOG_TREE1,tname,tlabel,tnamep,ttype);

  }

  //expand tree

  ProTKSprintf(tname,"NodeName0");

  ProUITreeNodeExpand(XD_ADDNOTEDIALOG_DIALOG,XD_ADDNOTEDIALOG_TREE1,tname,PRO_B_TRUE);

  //free mem

  ProUITreeNodeTypeFree(tntd);

  ProUITreeNodeTypeFree(tnte);