Exemplo n.º 1
0
        public IXBody DeserializeBody(Stream stream)
        {
            var comStr = new StreamWrapper(stream);
            var body   = (IBody2)m_Modeler.Restore(comStr);

            return(m_App.CreateObjectFromDispatch <ISwTempBody>(body, null));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 从文件加载实体
        /// </summary>
        /// <param name="app"></param>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static IBody2 LoadBodyFromFile(ISldWorks app, string filePath)
        {
            IStream stream = null;

            CreateStreamOnHGlobal(IntPtr.Zero, true, ref stream);

            var comStream = new ComStreamBody(ref stream, true, true);

            using (var fileStream = File.OpenRead(filePath))
            {
                fileStream.CopyTo(comStream);
                comStream.Seek(0, SeekOrigin.Begin);
            }

            IModeler modeler = app.IGetModeler();

            return((IBody2)modeler.Restore(stream));
        }