从选定的3D实体获取句柄代码

时间:2016-04-29 03:44:04

标签: c# autocad autodesk

我在用户表格中使用Autodesk设计审核控制&我想从3D实体对象中获取句柄代码,我也想获得对象的一些属性,如图层名称,颜色等。

我尝试了下面列出的两个代码解决方案,但仍然无法获得我需要的内容。

    private ECompositeViewer.IAdECompositeViewer CompositeViewer;
    private ECompositeViewer.IAdSection Section;
    private AdCommon.IAdCollection MyObjects, MyObjectProperties;
    private AdCommon.IAdUserCollection MyObjectsNamedCollection;
    private ECompositeViewer.IAdContent ObjectContent;

 private void axCExpressViewerControl1_OnSelectObjectEx(object sender,AxExpressViewerDll.IAdViewerEvents_OnSelectObjectExEvent e)
    {
        Get_Handle_Code();
    }

    void Get_Handle_Code()
    {

        CompositeViewer = (ECompositeViewer.IAdECompositeViewer)axCExpressViewerControl1.ECompositeViewer; Section = (ECompositeViewer.IAdSection)CompositeViewer.Section;
        ObjectContent = (ECompositeViewer.IAdContent)Section.Content;
        MyObjectsNamedCollection = (AdCommon.IAdUserCollection)ObjectContent.CreateUserCollection();
        MyObjects = (AdCommon.IAdCollection)ObjectContent.get_Objects(1); //0 is to return all objects

       foreach (ECompositeViewer.IAdObject MyObject in MyObjects)
       {
           AdCommon.IAdObject2 obj = (AdCommon.IAdObject2)MyObject;
           MessageBox.Show("Object ID is  " + obj.Id.ToString());


           MyObjectProperties = (AdCommon.IAdCollection) MyObject.Properties;
           foreach (AdCommon.IAdProperty MyObjectProperty in MyObjectProperties)    
           {
               MessageBox.Show(MyObjectProperty.Name.ToString() + " / " + MyObjectProperty.Value.ToString());

           }
       }  
    }

DWF viewer control in a userform

对象ID消息框:

enter image description here

对象名称和值:

enter image description here

提前致谢

0 个答案:

没有答案