SP3D提取模型实体到IGES或SAT格式

using System;
using System.Linq;
using System.Runtime.InteropServices;
using Ingr.SP3D.Common.Client;
using Ingr.SP3D.Common.Client.Services;
using Ingr.SP3D.Common.Middle;
using Ingr.SP3D.Common.Middle.Services;
using Ingr.SP3D.Structure.Middle;
using Microsoft.VisualBasic;
using Ingr.SP3D.Common.Middle.Services.Hidden;
using Ingr.SP3D.Space.Middle.Services;
using Ingr.SP3D.Planning.Middle;

namespace ClassLibrary1
{
    public class Class1 : BaseModalCommand
    {
        public override void OnStart(int instanceId, object argument)
        {
            base.OnStart(instanceId, argument);
            var ssObjs = ClientServiceProvider.SelectSet.SelectedObjects;
            if (ssObjs.Count == 0)
            {
                Interaction.MsgBox("please select some objects first!", MsgBoxStyle.Exclamation, null);
            }
            try
            {
                foreach (var item in ssObjs)
                {
                    try
                    {
                        var fn = System.IO.Path.Combine(@"Z:\E\Test", (item as INamedItem).Name + $"_{item.ObjectID}.iges");
                        SpatialQueryHelper.Export(item, SpatialQueryHelper.ExportType.IGES, fn);
                        SpatialQueryHelper.Export(item, SpatialQueryHelper.ExportType.SAT, System.IO.Path.ChangeExtension(fn,".sat"));
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                Interaction.MsgBox("export complate!", MsgBoxStyle.Information, null);
            }
            catch (Exception ex)
            {
                Interaction.MsgBox(ex.StackTrace, MsgBoxStyle.Exclamation, null);
            }
        }

        protected override void StopCommand()
        {
            base.StopCommand();
            base.WriteStatusBarMsg("exit commmand.....");
        }
    }
}

生成iges或者sat后用AutoCAD/中望CAD导入即可

AutoCAD 2025 帮助 | IMPORT(命令) | Autodesk

 

 

posted @ 2025-05-02 17:18  南胜NanSheng  阅读(267)  评论(0)    收藏  举报