iT邦幫忙

0

[Aras 筆記]Technical Document 工具製作(1) - 製作CAD表格

2018-10-25 18:30:57338 瀏覽

原廠安裝完畢後,開始使用Technical Document如下圖

  1. 新增物件,並使用Standard Schema
    https://ithelp.ithome.com.tw/upload/images/20181025/201065035a8q8f0Fqm.png
  2. 在設計頁面加入ItemInfo,選擇CAD物件之後顯示該表格資訊
    https://ithelp.ithome.com.tw/upload/images/20181025/20106503g7ancWSOSH.png

現在,我需要將ItemInfo改寫成有包含子階工程圖的表格,步驟如下

  1. 首先進入Schema
    https://ithelp.ithome.com.tw/upload/images/20181025/20106503KbsND8GPk4.png

  2. 在Content 加入新功能CADInfo
    https://ithelp.ithome.com.tw/upload/images/20181025/20106503KWFrag1jYx.png

  3. 在Xml Schema Element新增CADInfo的物件
    https://ithelp.ithome.com.tw/upload/images/20181025/20106503pStICwHqyj.png

  4. 新增一個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);
        }
    }
}

外觀修改

  1. 在Output Setting 中修改Standard Style Settings
    https://ithelp.ithome.com.tw/upload/images/20181025/20106503HRCdSpx1dQ.png
  2. 將css寫入Style
    https://ithelp.ithome.com.tw/upload/images/20181025/20106503WWPWhATpxp.png
  3. 重新開啟Technical Document
    https://ithelp.ithome.com.tw/upload/images/20181025/20106503NlgnePZVla.png

尚未有邦友留言

立即登入留言