VectorDraw常見問題整理:如何隱藏自定義ACAD對象?

    VectorDraw Developer Framework(VDF)是一個用於應用程序可視化的圖形引擎庫。有了VDF提供的功能,您可以輕鬆地創建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。該庫還支持許多矢量和柵格輸入和輸出格式,包括本地PDF和SVG導出。


問:

    隨附的圖形在VDraw和AutoCAD中看起來不同。有什麼方法可以過濾VdfCAD / VDraw中不需要的AecDb…-vdInserts?

答:

    您可以嘗試使用AfterOpen事件來過濾此類塊/實體,並將其隱藏在凍結層中。例如嘗試代碼:

private void button5_Click(object sender, EventArgs e)
{
    doc = vdFramedControl1.BaseControl.ActiveDocument;
    doc.OnAfterOpenDocument += new vdDocument.AfterOpenDocument(doc_OnAfterOpenDocument);
    doc.Open(@"MyDrawing.dwg");
}
 
void doc_OnAfterOpenDocument(object sender)
{
    vdLayer aeclay = doc.Layers.FindName("AECLAYER"); // THE layer where these are going to be hidden
    if (aeclay == null)
    {
        aeclay = new vdLayer(doc, "AECLAYER");
        doc.Layers.AddItem(aeclay);
    }
    aeclay.Frozen = true; // set to frozen
 
 
    foreach (vdBlock item in doc.Blocks) // check all blocks
    {
        bool is_aec = false;
        foreach (vdFigure fig in item.Entities)
        {
            vdText txt = fig as vdText;
            if (txt != null)
            {// Filter is to contain the text AecDb.. and has less than 3 items /
             //  You can alter this filter as you like.
                if (txt.TextString.ToUpper().Contains("AECDB") && item.Entities.Count<3)
                {// that contain the string AecDB...
                    is_aec = true;
                    break;
                }
            }
        }
        if (is_aec)
        {
            foreach (vdFigure fig in item.Entities)
            {
                fig.Layer = aeclay; // hide the entities of this block
            }
            is_aec = false;
        }
    }
}

    對於以上問答,如果您有任何的疑惑都可以在評論區留言,我們會及時回覆。此係列的問答教程我們會持續更新,如果您感興趣,可以多多關注本教程。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章