santoshr0114 - Monday, January 5, 2015 11:50 PM:
Hi All,
How can i get the Document Structure(Shown in the CAD Document Structure Tab) and download its native files to a folder.
Below is my code which i am trying
Aras.IOM.Item CADItem = MyInnovator.getItemByKeyedName("CAD", item_number);
Aras.IOM.Item CadStructure = CADItem.getRelationships("CAD Structure");
int struct_count = CadStructure.getItemCount();
for (int i = 0; i < struct_count; i++)
{
}
In the for loop i am trying to download the file.
But my CadStructure always returns null. Am i doing anything wrong.
The CADItem has structure as its a Assembly CAD Document, i can see it in ARAS Innovator Client.
DavidSpackman - Tuesday, January 6, 2015 7:46 PM:
Hi Santosh,
Something like this should be get started
Item CADItemsQuery = MyInnovator.newItem("CAD", "get");
CADItemsQuery.setAttribute("select", "id,created_on,item_number");
Item CADstuctureQuery = MyInnovator.newItem("CAD Structure", "get");
CADItemsQuery.addRelationship(CADstuctureQuery);
Item CADItemsResult = CADItemsQuery.apply();
Item CADItems = CADItemsResult.getItemsByXPath("//Result/Item[@type='CAD']");
Console.WriteLine("Item Number" + " " + "ID" + " " + "Relationship Count");
for (int i = 0; i < CADItems.getItemCount(); i++)
{
Item CADItem = CADItemsResult.getItemByIndex(i);
Item CADStructures = CADItem.getItemsByXPath("//Item[id='" + CADItem.getProperty("id") + "']/Relationships/Item[@type='CAD Structure']");
Console.WriteLine(CADItem.getProperty("item_number") + " " + CADItem.getProperty("id") + " " + CADStructures.getItemCount());
}
David
DavidSpackman - Tuesday, January 6, 2015 8:07 PM:
Here is another method to get the relationships if you are only looking for a single item
Item itm = MyInnovator.newItem("CAD", "get");
itm.setAttribute("select", "id,created_on,item_number");
itm.setProperty("item_number", "CAD-00001138");
itm = itm.apply();
itm.fetchRelationships("CAD Structure");
Item relationships = itm.getRelationships("CAD Structure");
int count = relationships.getItemCount();
David
santoshr0114 - Wednesday, January 7, 2015 12:56 AM:
Thank you David. You code worked. This will get me started.
I am still unable to get the item_numbers of the CAD documents from relationships
i.e.,
Item itm = MyInnovator.newItem("CAD", "get");
itm.setAttribute("select", "id,created_on,item_number");
itm.setProperty("item_number", "CAD-00001138");
itm = itm.apply();
itm.fetchRelationships("CAD Structure");
Item relationships = itm.getRelationships("CAD Structure");
int count = relationships.getItemCount();
for (int i = 0; i < count; i++)
{
Aras.IOM.Item CadStructureItems = relationships.getItemByIndex(i);
Console.WriteLine(CadStructureItems.getProperty("item_number"));
// Get the related item_number (i.e., CAD Document item_number)
// When i try to iterate it gives me an error saying "NOT A SINGLE ITEM"
}
When i saw the AML value from the CadStructureItems. i see all the relationships rather only one (as i am using getItemByIndex())
Any Idea ?
DavidSpackman - Thursday, January 8, 2015 7:12 PM:
Hi Santosh,
Have you reviewed the Aras Programmers Guide? That should be able to provide you with some good examples.
Here is an example for what you need (See 7.5 Query for an Item and return its configuration in the Aras Programmers Guide for something similar)
// Set up the query Item.
Item CADItemsQuery = MyInnovator.newItem("CAD", "get");
CADItemsQuery.setAttribute("select", "item_number,name,description");
// Add the CAD Structure
Item CADstuctureQuery = MyInnovator.newItem("CAD Structure", "get");
CADstuctureQuery.setAttribute("select","quantity,related_id(item_number,name,description)");
CADItemsQuery.addRelationship(CADstuctureQuery);
// Perform the query.
Item CADItemsResult = CADItemsQuery.apply();
// Test for an error.
if (CADItemsResult.isError())
{
return MyInnovator.newError("Item not found: " + CADItemsResult.getErrorDetail());
}
//Get only CAD items
Item CADItems = CADItemsResult.getItemsByXPath("//Result/Item[@type='CAD']");
Console.WriteLine("Item Number" + " " + "ID" + " " + "Relationship Count");
// Iterate over the CAD Items.
for (int i = 0; i < CADItems.getItemCount(); i++)
{
Item CADItem = CADItemsResult.getItemByIndex(i);
// Get a handle to the BOM Items.
Item CADStructures = CADItem.getRelationships("CAD Structure");
int CADStructuresCount = CADStructures.getItemCount();
Console.WriteLine(CADItem.getProperty("item_number") + " " + CADItem.getProperty("id") + " " + CADStructuresCount);
// Iterate over the CAD Structure Items.
for (int j = 0; j < CADStructuresCount; j++)
{
// Get a handle to the relationship Item by index.
Item CADStructure = CADStructures.getItemByIndex(j);
// Get a handle to the related Item for this relationship Item.
Item CADStructureCADItem = CADStructure.getRelatedItem();
Console.WriteLine("* " + CADStructureCADItem.getProperty("item_number") + " " + CADStructureCADItem.getProperty("id"));
}
}
David
AbhishekSrivastava - Thursday, January 21, 2016 3:32 AM:
Hi friends,
This code is for link product and part file. when we open product file part file linked or something else
santoshr0114 - Friday, January 9, 2015 5:43 AM:
Hi David,
Yes i have gone through the ARAS Programmers Guide. I also went through the topic 7.5 you mentioned. I missed to call getRelatedItem()
Thank for guiding...
I ll go through the programmers guide once again.