原厂安装完毕后,开始使用Technical Document如下图
新增物件,并使用Standard Schema

现在,我需要将ItemInfo改写成有包含子阶工程图的表格,步骤如下
首先进入Schema
在Content 加入新功能CADInfo
在Xml Schema Element新增CADInfo的物件
新增一个Method,複製tp_ItemInfoContentGenerator的方法内容,加入CAD Structure的逻辑
//MethodTemplateName=CSharp:Aras.TDF.ContentGenerator(Strict);ItemDocumentElement targetItem = targetElement as ItemDocumentElement;if (targetItem != null) { targetItem.ClearChilds(); // if referenced item was set, then if (!targetItem.IsEmpty) { TableDocumentElement tableElement = (TableDocumentElement) this.Factory.NewTable("Table", 3, 5); tableElement.GetCell(0, 0).AddChild(this.Factory.NewText("Title", "Item Info Table")); for (int i = 0; i < tableElement.CellCount; i++) { tableElement.MergeCells(0, i, MergeDirection.Right); } tableElement.GetCell(1, 0).AddChild(this.Factory.NewText("Title", "Id")); tableElement.GetCell(1, 1).AddChild(this.Factory.NewText("Title", "Name")); tableElement.GetCell(1, 2).AddChild(this.Factory.NewText("Title", "Classification")); tableElement.GetCell(1, 3).AddChild(this.Factory.NewText("Title", "Status")); tableElement.GetCell(1, 4).AddChild(this.Factory.NewText("Title", "Date of creation")); tableElement.GetCell(2, 0).AddChild(this.Factory.NewText("Title", targetItem.ItemId)); tableElement.GetCell(2, 1).AddChild(this.Factory.NewText("Title", targetItem.GetItemProperty("name", " "))); tableElement.GetCell(2, 2).AddChild(this.Factory.NewText("Title", targetItem.GetItemProperty("classification", " "))); tableElement.GetCell(2, 3).AddChild(this.Factory.NewText("Title", targetItem.GetItemProperty("state", " "))); tableElement.GetCell(2, 4).AddChild(this.Factory.NewText("Title", targetItem.GetItemProperty("created_on"))); targetItem.AddChild(tableElement); Item components = this.Factory.InnovatorInstance.newItem("CAD Structure","get"); components.setAction("get"); components.setAttribute("where","CAD_Structure.source_id='" + targetItem.ItemId + "'"); components = components.apply(); // if referenced item was set, then if (!components.isError()) { TableDocumentElement tableElementBOM = (TableDocumentElement) this.Factory.NewTable("Table", (components.getItemCount() + 2), 5); tableElementBOM.GetCell(0, 0).AddChild(this.Factory.NewText("Title", "Components List")); for (int i = 0; i < tableElementBOM.CellCount; i++) { tableElementBOM.MergeCells(0, i, MergeDirection.Right); } tableElementBOM.GetCell(1, 0).AddChild(this.Factory.NewText("Title", "Sort")); tableElementBOM.GetCell(1, 1).AddChild(this.Factory.NewText("Title", "Number")); tableElementBOM.GetCell(1, 2).AddChild(this.Factory.NewText("Title", "Name")); tableElementBOM.GetCell(1, 3).AddChild(this.Factory.NewText("Title", "Classification")); tableElementBOM.GetCell(1, 4).AddChild(this.Factory.NewText("Title", "File")); for (int i = 0; i < components.getItemCount(); i++) { Item c = components.getItemByIndex(i); Item p = c.getItemsByXPath("related_id/Item"); int r = i + 2; tableElementBOM.GetCell(r, 0).AddChild(this.Factory.NewText("Text", c.getProperty("sort_order", " "))); tableElementBOM.GetCell(r, 1).AddChild(this.Factory.NewText("Text", p.getProperty("item_number"))); tableElementBOM.GetCell(r, 2).AddChild(this.Factory.NewText("Text", p.getProperty("name"))); tableElementBOM.GetCell(r, 3).AddChild(this.Factory.NewText("Text", c.getProperty("classification", " "))); tableElementBOM.GetCell(r, 4).AddChild(this.Factory.NewText("Text", p.getProperty("native_file",""))); } targetItem.AddChild(tableElementBOM); } }}
外观修改
在Output Setting 中修改Standard Style Settings

