明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 20763|回复: 35

[图形系统] Teigha的简单应用 DwgView

  [复制链接]
发表于 2014-7-15 13:05 | 显示全部楼层 |阅读模式
本帖最后由 雪山飞狐_lzh 于 2014-7-17 18:09 编辑

1998

2月,独立的、非营利的"OpenDWG Alliance" 组织成立,目标是让dwg文件成为一个开放的、大家都可以用的图形存储标准。这个联盟是由Visio牵头的多家公司组成的。

"OpenDWG Alliance"致力于开发读写dwg文件的程序,开始开发供成员使用的OpenDWG Toolkit和 Viewkit(在以前 MarComp 发AUTODIRECT 库基础上)





Teigha即DWGdirect(OpenDWG
关于Teigha的由来可以看看这个http://www.25kx.com/art/706332
Teigha的最新版是4.0
但是我只在CSDN上找到了较老的3.03版,但基本能用。。。
下面是个简单的测试例子

  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Windows.Forms;
  6. using System.Drawing;

  7. using TDb = Teigha.DatabaseServices;
  8. using TRx = Teigha.Runtime;
  9. using TGe = Teigha.Geometry;
  10. using TGi = Teigha.GraphicsInterface;
  11. using TGs = Teigha.GraphicsSystem;


  12. namespace TlsCad.Trans
  13. {
  14.     public class DwgView : IDisposable
  15.     {
  16.         private Panel _panel = null;

  17.         private TDb.Database _db;
  18.         private TGs.LayoutHelperDevice _dev = null;
  19.         private Graphics _graphics = null;

  20.         public Panel Panel
  21.         {
  22.             set
  23.             {
  24.                 _panel = value;
  25.                 InitializeGraphics();
  26.             }
  27.             get
  28.             {
  29.                 return _panel;
  30.             }
  31.         }

  32.         public TDb.Database Database
  33.         {
  34.             get { return _db; }
  35.         }

  36.         private void ReSize()
  37.         {
  38.             if (_dev != null)
  39.             {
  40.                 Rectangle rec = _panel.Bounds;
  41.                 rec.Offset(-_panel.Location.X, -_panel.Location.Y);
  42.                 // HDC assigned to the device corresponds to the whole client area of the panel
  43.                 _dev.OnSize(rec);
  44.             }
  45.         }

  46.         protected void OnPaint(object sender, PaintEventArgs e)
  47.         {
  48.             if (_dev != null)
  49.             {
  50.                 _dev.Update();
  51.             }
  52.         }

  53.         protected void OnReSize(object sender, EventArgs e)
  54.         {
  55.             ReSize();
  56.         }

  57.         public DwgView(Panel panel)
  58.         {
  59.             _db = new TDb.Database(true, false);
  60.             _panel = panel;
  61.             InitializeGraphics();
  62.         }

  63.         public DwgView(Panel panel, string dwgFileName)
  64.         {
  65.             _db = new TDb.Database(false, false);
  66.             _db.ReadDwgFile(dwgFileName, TDb.FileOpenMode.OpenForReadAndAllShare, true, "");
  67.             _panel = panel;
  68.             InitializeGraphics();
  69.         }

  70.         private void InitializeGraphics()
  71.         {
  72.             _graphics = Graphics.FromHwnd(_panel.Handle);
  73.             _panel.Resize += OnReSize;
  74.             _panel.Paint += OnPaint;
  75.             //rendering module (may be also "WinDirectX" or "WinOpenGL")
  76.             using (var module = (TGs.GsModule)TRx.SystemObjects.DynamicLinker.LoadModule("WinOpenGL.txv", false, true))
  77.             {

  78.                 if (module != null)
  79.                 {
  80.                     // create graphics device
  81.                     using (var device = module.CreateDevice())
  82.                     {

  83.                         if (device != null)
  84.                         {
  85.                             //setup device properties
  86.                             using (TRx.Dictionary props = device.Properties)
  87.                             {
  88.                                 if (props.Contains("WindowHWND")) // Check if property is supported
  89.                                     props.AtPut("WindowHWND", new TRx.RxVariant(_panel.Handle)); // hWnd necessary for DirectX device
  90.                                 if (props.Contains("WindowHDC")) // Check if property is supported
  91.                                     props.AtPut("WindowHDC", new TRx.RxVariant(_graphics.GetHdc())); // hWindowDC necessary for Bitmap device
  92.                                 if (props.Contains("DoubleBufferEnabled")) // Check if property is supported
  93.                                     props.AtPut("DoubleBufferEnabled", new TRx.RxVariant(true));
  94.                                 if (props.Contains("EnableSoftwareHLR")) // Check if property is supported
  95.                                     props.AtPut("EnableSoftwareHLR", new TRx.RxVariant(true));
  96.                                 if (props.Contains("DiscardBackFaces")) // Check if property is supported
  97.                                     props.AtPut("DiscardBackFaces", new TRx.RxVariant(true));

  98.                             }

  99.                             var ctx = new TGi.ContextForDbDatabase(_db);
  100.                             ctx.UseGsModel = true;
  101.                             _dev = TGs.LayoutHelperDevice.SetupActiveLayoutViews(device, ctx);
  102.                             _dev.UserGiContext = ctx;
  103.                             _dev.SetLogicalPalette(TGs.Device.DarkPalette);
  104.                             Rectangle rec = _panel.Bounds;
  105.                             rec.Offset(-_panel.Location.X, -_panel.Location.Y);
  106.                             // HDC assigned to the device corresponds to the whole client area of the panel
  107.                             _dev.OnSize(rec);
  108.                         }
  109.                     }
  110.                 }
  111.             }
  112.         }

  113.         public void AddEntity(params TDb.Entity[] ents)
  114.         {
  115.             using (var tr = _db.TransactionManager.StartTransaction())
  116.             {
  117.                 var btr = (TDb.BlockTableRecord)tr.GetObject(_db.CurrentSpaceId, TDb.OpenMode.ForWrite);
  118.                 foreach (var ent in ents)
  119.                 {
  120.                     btr.AppendEntity(ent);
  121.                     tr.AddNewlyCreatedDBObject(ent, false);
  122.                 }
  123.                 tr.Commit();
  124.             }
  125.         }

  126.         public void AddEntity(IEnumerable<TDb.Entity> ents)
  127.         {
  128.             using (var tr = _db.TransactionManager.StartTransaction())
  129.             {
  130.                 var btr = (TDb.BlockTableRecord)tr.GetObject(_db.CurrentSpaceId, TDb.OpenMode.ForWrite);
  131.                 foreach (var ent in ents)
  132.                 {
  133.                     btr.AppendEntity(ent);
  134.                     tr.AddNewlyCreatedDBObject(ent, false);
  135.                 }
  136.                 tr.Commit();
  137.             }
  138.         }

  139.         public void Zoom(TGe.BoundBlock3d box)
  140.         {

  141.             using (var vtr = (TDb.ViewportTableRecord)_db.CurrentViewportTableRecordId.GetObject(TDb.OpenMode.ForWrite))
  142.             {
  143.                 // using protocol extensions we handle PS and MS viewports in the same manner
  144.                 using (var vpd = new TDb.AbstractViewportData(vtr))
  145.                 {
  146.                     var view = vpd.GsView;
  147.                     // do actual zooming - change GS view
  148.                     // here protocol extension is used again, that provides some helpful functions
  149.                     using (var vpe = new TDb.AbstractViewPE(view))
  150.                     {
  151.                         box.TransformBy(view.ViewingMatrix);
  152.                         vpe.ZoomExtents(box);
  153.                     }
  154.                     vpd.SetView(view);
  155.                 }
  156.             }
  157.             ReSize();
  158.         }


  159.         public void Zoom(TDb.Extents3d ext)
  160.         {
  161.             TGe.BoundBlock3d box = new TGe.BoundBlock3d();
  162.             box.Set(ext.MinPoint, ext.MaxPoint);
  163.             Zoom(box);
  164.         }

  165.         public void ZoomWindow(TGe.Point3d minPoint, TGe.Point3d maxPoint)
  166.         {
  167.             TGe.BoundBlock3d box = new TGe.BoundBlock3d();
  168.             box.Set(minPoint, maxPoint);
  169.             Zoom(box);
  170.         }

  171.         private bool GetLayoutExtents(TDb.Database db, TGs.View view, ref TGe.BoundBlock3d box)
  172.         {
  173.             var bt = (TDb.BlockTable)db.BlockTableId.GetObject(TDb.OpenMode.ForRead);
  174.             var space = (TDb.BlockTableRecord)bt[TDb.BlockTableRecord.PaperSpace].GetObject(TDb.OpenMode.ForRead);
  175.             var layout = (TDb.Layout)space.LayoutId.GetObject(TDb.OpenMode.ForRead);
  176.             var ext = new TDb.Extents3d();
  177.             if (layout.GetViewports().Count > 0)
  178.             {
  179.                 bool bOverall = true;
  180.                 foreach (TDb.ObjectId id in layout.GetViewports())
  181.                 {
  182.                     if (bOverall)
  183.                     {
  184.                         bOverall = false;
  185.                         continue;
  186.                     }
  187.                     var pVp = (TDb.Viewport)id.GetObject(TDb.OpenMode.ForRead);
  188.                 }
  189.                 ext.TransformBy(view.ViewingMatrix);
  190.                 box.Set(ext.MinPoint, ext.MaxPoint);
  191.             }
  192.             else
  193.             {
  194.                 ext = layout.Extents;
  195.             }
  196.             box.Set(ext.MinPoint, ext.MaxPoint);
  197.             return ext.MinPoint != ext.MaxPoint;
  198.         }

  199.         public void ZoomExtents()
  200.         {

  201.             using (var vtr = _db.CurrentViewportTableRecordId.GetObject(TDb.OpenMode.ForWrite))
  202.             {
  203.                 // using protocol extensions we handle PS and MS viewports in the same manner
  204.                 using (var vpd = new TDb.AbstractViewportData(vtr))
  205.                 {
  206.                     var view = vpd.GsView;
  207.                     // do actual zooming - change GS view
  208.                     // here protocol extension is used again, that provides some helpful functions
  209.                     using (var vpe = new TDb.AbstractViewPE(view))
  210.                     {
  211.                         TGe.BoundBlock3d box = new TGe.BoundBlock3d();
  212.                         bool bValid = vpe.GetViewExtents(box);

  213.                         if (vtr is TDb.Viewport && ((TDb.Viewport)vtr).Number == 1)
  214.                         {
  215.                             if (!bValid || !(box.GetMinimumPoint().X < box.GetMaximumPoint().X && box.GetMinimumPoint().Y < box.GetMaximumPoint().Y))
  216.                             {
  217.                                 bValid = GetLayoutExtents(_db, view, ref box);
  218.                             }
  219.                         }
  220.                         else if (!bValid) // model space viewport
  221.                         {
  222.                             bValid = GetLayoutExtents(_db, view, ref box);
  223.                         }

  224.                         if (!bValid)
  225.                         {
  226.                             // set to somewhat reasonable (e.g. paper size)
  227.                             if (_db.Measurement == TDb.MeasurementValue.Metric)
  228.                             {
  229.                                 box.Set(TGe.Point3d.Origin, new TGe.Point3d(297.0, 210.0, 0.0)); // set to papersize ISO A4 (portrait)
  230.                             }
  231.                             else
  232.                             {
  233.                                 box.Set(TGe.Point3d.Origin, new TGe.Point3d(11.0, 8.5, 0.0)); // ANSI A (8.50 x 11.00) (landscape)
  234.                             }
  235.                             box.TransformBy(view.ViewingMatrix);
  236.                         }
  237.                         vpe.ZoomExtents(box);
  238.                     }
  239.                     vpd.SetView(view);
  240.                 }
  241.             }
  242.             ReSize();
  243.         }

  244.         public void Dispose()
  245.         {

  246.             if (_db != null)
  247.             {
  248.                 _db.Dispose();
  249.                 _db = null;
  250.             }

  251.             if (_dev != null)
  252.             {
  253.                 _dev.Dispose();
  254.                 _dev = null;
  255.             }

  256.         }
  257.     }
  258. }



  1. /////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2003-2014, Open Design Alliance (the "Alliance").
  2. // All rights reserved.
  3. //
  4. // This software and its documentation and related materials are owned by
  5. // the Alliance. The software may only be incorporated into application
  6. // programs owned by members of the Alliance, subject to a signed
  7. // Membership Agreement and Supplemental Software License Agreement with the
  8. // Alliance. The structure and organization of this software are the valuable  
  9. // trade secrets of the Alliance and its suppliers. The software is also
  10. // protected by copyright law and international treaty provisions. Application  
  11. // programs incorporating this software must include the following statement
  12. // with their copyright notices:
  13. //   
  14. //   This application incorporates Teigha(R) software pursuant to a license
  15. //   agreement with Open Design Alliance.
  16. //   Teigha(R) Copyright (C) 2003-2014 by Open Design Alliance.
  17. //   All rights reserved.
  18. //
  19. // By use of this software, its documentation or related materials, you
  20. // acknowledge and accept the above terms.
  21. ///////////////////////////////////////////////////////////////////////////////
  22. using System;
  23. using System.Collections.Generic;
  24. using System.Text;

  25. using Teigha;
  26. using Teigha.DatabaseServices;

  27. using Microsoft.Win32;

  28. namespace TlsCad.ApplicationServices
  29. {
  30.     class HostAppServ : HostApplicationServices
  31.     {
  32.         public HostAppServ()
  33.         {
  34.         }

  35.         public String FindConfigPath(String configType)
  36.         {
  37.             String subkey = GetRegistryAcadProfilesKey();
  38.             if (subkey.Length > 0)
  39.             {
  40.                 subkey += String.Format("\\General");
  41.                 String searchPath;
  42.                 if (GetRegistryString(Registry.CurrentUser, subkey, configType, out searchPath))
  43.                     return searchPath;
  44.             }
  45.             return String.Format("");
  46.         }

  47.         private String FindConfigFile(String configType, String file)
  48.         {
  49.             String searchPath = FindConfigPath(configType);
  50.             if (searchPath.Length > 0)
  51.             {
  52.                 searchPath = String.Format("{0}\\{1}", searchPath, file);
  53.                 if (System.IO.File.Exists(searchPath))
  54.                     return searchPath;
  55.             }
  56.             return String.Format("");
  57.         }

  58.         public override String FindFile(String file, Database db, FindFileHint hint)
  59.         {
  60.             String sFile = this.FindFileEx(file, db, hint);
  61.             if (sFile.Length > 0)
  62.                 return sFile;

  63.             String strFileName = file;
  64.             String ext;
  65.             if (strFileName.Length > 3)
  66.                 ext = strFileName.Substring(strFileName.Length - 4, 4).ToUpper();
  67.             else
  68.                 ext = file.ToUpper();
  69.             if (ext == String.Format(".PC3"))
  70.                 return FindConfigFile(String.Format("PrinterConfigDir"), file);
  71.             if (ext == String.Format(".STB") || ext == String.Format(".CTB"))
  72.                 return FindConfigFile(String.Format("PrinterStyleSheetDir"), file);
  73.             if (ext == String.Format(".PMP"))
  74.                 return FindConfigFile(String.Format("PrinterDescDir"), file);

  75.             switch (hint)
  76.             {
  77.                 case FindFileHint.FontFile:
  78.                 case FindFileHint.CompiledShapeFile:
  79.                 case FindFileHint.TrueTypeFontFile:
  80.                 case FindFileHint.PatternFile:
  81.                 case FindFileHint.FontMapFile:
  82.                 case FindFileHint.TextureMapFile:
  83.                     break;
  84.                 default:
  85.                     return sFile;
  86.             }

  87.             if (hint != FindFileHint.TextureMapFile && ext != String.Format(".SHX") && ext != String.Format(".PAT") && ext != String.Format(".TTF") && ext != String.Format(".TTC"))
  88.             {
  89.                 strFileName += String.Format(".shx");
  90.             }
  91.             else if (hint == FindFileHint.TextureMapFile)
  92.             {
  93.                 strFileName.Replace(String.Format("/"), String.Format("\\"));
  94.                 int last = strFileName.LastIndexOf("\\");
  95.                 if (last == -1)
  96.                     strFileName = "";
  97.                 else
  98.                     strFileName = strFileName.Substring(0, last);
  99.             }


  100.             sFile = (hint != FindFileHint.TextureMapFile) ? GetRegistryACADFromProfile() : GetRegistryAVEMAPSFromProfile();
  101.             while (sFile.Length > 0)
  102.             {
  103.                 int nFindStr = sFile.IndexOf(";");
  104.                 String sPath;
  105.                 if (-1 == nFindStr)
  106.                 {
  107.                     sPath = sFile;
  108.                     sFile = String.Format("");
  109.                 }
  110.                 else
  111.                 {
  112.                     sPath = String.Format("{0}\\{1}", sFile.Substring(0, nFindStr), strFileName);
  113.                     if (System.IO.File.Exists(sPath))
  114.                     {
  115.                         return sPath;
  116.                     }
  117.                     sFile = sFile.Substring(nFindStr + 1, sFile.Length - nFindStr - 1);
  118.                 }
  119.             }

  120.             if (hint == FindFileHint.TextureMapFile)
  121.             {
  122.                 return sFile;
  123.             }

  124.             if (sFile.Length <= 0)
  125.             {
  126.                 String sAcadLocation = GetRegistryAcadLocation();
  127.                 if (sAcadLocation.Length > 0)
  128.                 {
  129.                     sFile = String.Format("{0}\\Fonts\\{1}", sAcadLocation, strFileName);
  130.                     if (System.IO.File.Exists(sFile))
  131.                     {
  132.                         sFile = String.Format("{0}\\Support\\{1}", sAcadLocation, strFileName);
  133.                         if (System.IO.File.Exists(sFile))
  134.                         {
  135.                             sFile = String.Format("");
  136.                         }
  137.                     }
  138.                 }
  139.             }
  140.             return sFile;
  141.         }

  142.         public override bool GetPassword(String fileName, PasswordOptions options, out String pass)
  143.         {
  144.             //PasswordDlg pwdDlg = new PasswordDlg();
  145.             /*pwdDlg.TextFileName.Text = fileName;
  146.             if (pwdDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  147.             {
  148.               pass = pwdDlg.password.Text;
  149.               return true;
  150.             }*/
  151.             pass = String.Format("");
  152.             return false;
  153.         }

  154.         public override String FontMapFileName
  155.         {
  156.             get
  157.             {
  158.                 String subkey = GetRegistryAcadProfilesKey();
  159.                 if (subkey.Length > 0)
  160.                 {
  161.                     subkey += String.Format("\\Editor Configuration");
  162.                     String fontMapFile;
  163.                     if (GetRegistryString(Registry.CurrentUser, subkey, String.Format("FontMappingFile"), out fontMapFile))
  164.                         return fontMapFile;
  165.                 }
  166.                 return String.Format("");
  167.             }
  168.         }

  169.         bool GetRegistryString(RegistryKey rKey, String subkey, String name, out String value)
  170.         {
  171.             bool rv = false;
  172.             object objData = null;

  173.             RegistryKey regKey;
  174.             regKey = rKey.OpenSubKey(subkey);
  175.             if (regKey != null)
  176.             {
  177.                 objData = regKey.GetValue(name);
  178.                 if (objData != null)
  179.                 {
  180.                     rv = true;
  181.                 }
  182.                 regKey.Close();
  183.             }
  184.             if (rv)
  185.                 value = objData.ToString();
  186.             else
  187.                 value = String.Format("");

  188.             rKey.Close();
  189.             return rv;
  190.         }

  191.         String GetRegistryAVEMAPSFromProfile()
  192.         {
  193.             String subkey = GetRegistryAcadProfilesKey();
  194.             if (subkey.Length > 0)
  195.             {
  196.                 subkey += String.Format("\\General");
  197.                 // get the value for the ACAD entry in the registry
  198.                 String tmp;
  199.                 if (GetRegistryString(Registry.CurrentUser, subkey, String.Format("AVEMAPS"), out tmp))
  200.                     return tmp;
  201.             }
  202.             return String.Format("");
  203.         }

  204.         String GetRegistryAcadProfilesKey()
  205.         {
  206.             String subkey = String.Format("SOFTWARE\\Autodesk\\AutoCAD");
  207.             String tmp;

  208.             if (!GetRegistryString(Registry.CurrentUser, subkey, String.Format("CurVer"), out tmp))
  209.                 return String.Format("");
  210.             subkey += String.Format("\\{0}", tmp);

  211.             if (!GetRegistryString(Registry.CurrentUser, subkey, String.Format("CurVer"), out tmp))
  212.                 return String.Format("");
  213.             subkey += String.Format("\\{0}\\Profiles", tmp);

  214.             if (!GetRegistryString(Registry.CurrentUser, subkey, String.Format(""), out tmp))
  215.                 return String.Format("");
  216.             subkey += String.Format("\\{0}", tmp);
  217.             return subkey;
  218.         }

  219.         String GetRegistryAcadLocation()
  220.         {
  221.             String subkey = String.Format("SOFTWARE\\Autodesk\\AutoCAD");
  222.             String tmp;

  223.             if (!GetRegistryString(Registry.CurrentUser, subkey, String.Format("CurVer"), out tmp))
  224.                 return String.Format("");
  225.             subkey += String.Format("\\{0}", tmp);

  226.             if (!GetRegistryString(Registry.CurrentUser, subkey, String.Format("CurVer"), out tmp))
  227.                 return String.Format("");
  228.             subkey += String.Format("\\{0}", tmp);

  229.             if (!GetRegistryString(Registry.CurrentUser, subkey, String.Format(""), out tmp))
  230.                 return String.Format("");
  231.             return tmp;
  232.         }

  233.         String GetRegistryACADFromProfile()
  234.         {
  235.             String subkey = GetRegistryAcadProfilesKey();
  236.             if (subkey.Length > 0)
  237.             {
  238.                 subkey += String.Format("\\General");
  239.                 // get the value for the ACAD entry in the registry
  240.                 String tmp;
  241.                 if (GetRegistryString(Registry.CurrentUser, subkey, String.Format("ACAD"), out tmp))
  242.                     return tmp;
  243.             }
  244.             return String.Format("");
  245.         }
  246.     };
  247. }






本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x

评分

参与人数 1明经币 +3 金钱 +30 收起 理由
飞诗(fsxm) + 3 + 30 赞32个!

查看全部评分

发表于 2019-8-20 11:21 | 显示全部楼层
有没有最新的.net版本呢?
 楼主| 发表于 2014-7-15 13:06 | 显示全部楼层
本帖最后由 雪山飞狐_lzh 于 2014-7-15 13:25 编辑

测试的Form.cs
注意自己加panel控件和Resize 、FormClosed 事件

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;

  9. using TDb = Teigha.DatabaseServices;
  10. using TRx = Teigha.Runtime;
  11. using TGe = Teigha.Geometry;
  12. using TGi = Teigha.GraphicsInterface;
  13. using TGs = Teigha.GraphicsSystem;

  14. using TlsCad.ApplicationServices;

  15. namespace GhaTest
  16. {
  17.     public partial class Form1 : Form
  18.     {
  19.         TRx.Services _srv;
  20.         TlsCad.Trans.DwgView _dview;

  21.         public Form1()
  22.         {
  23.             _srv = new TRx.Services();
  24.             TDb.HostApplicationServices.Current = new HostAppServ();
  25.             InitializeComponent();

  26.             _dview = new TlsCad.Trans.DwgView(panel1);
  27.             //_dview.AddEntity(
  28.             //    new TDb.Line(new TGe.Point3d(-20, 0, 0), new TGe.Point3d(20, 0, 0)),
  29.             //    new TDb.Line(new TGe.Point3d(0, -20, 0), new TGe.Point3d(0, 20, 0)),
  30.             //    new TDb.Circle(TGe.Point3d.Origin, TGe.Vector3d.ZAxis, 10));

  31.             //_dview = new TlsCad.Trans.DwgView(panel1, "d:\\我的文档\\静力平衡6.dwg");

  32.             var txt = new TDb.DBText
  33.                 {
  34.                     Position = new TGe.Point3d(10,10,0),
  35.                     TextString = "123",
  36.                 };
  37.             txt.Height = 2;
  38.             var line = new TDb.Line(new TGe.Point3d(0, 0, 0), new TGe.Point3d(10, 10, 0));
  39.             _dview.AddEntity(txt, line);
  40.             _dview.ZoomExtents();
  41.             _dview.Database.SaveAs("d:\\11.dwg", TDb.DwgVersion.AC1800);
  42.         }

  43.         private void Form1_Resize(object sender, EventArgs e)
  44.         {
  45.             panel1.SetBounds(0, 0, Bounds.Width - 5, Bounds.Height - 30);
  46.         }

  47.         private void Form1_FormClosed(object sender, FormClosedEventArgs e)
  48.         {
  49.             _dview.Dispose();
  50.             _srv.Dispose();
  51.         }

  52.     }
  53. }

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2014-7-15 13:44 | 显示全部楼层
热烈欢迎雪山飞狐重出江湖!
发表于 2014-7-15 16:20 | 显示全部楼层
请问3.0版本的能读的最新的Dwg文件是哪个版本呢?Dwg 2010 2013 这两个版本能不能读?
 楼主| 发表于 2014-7-15 20:22 | 显示全部楼层
本帖最后由 雪山飞狐_lzh 于 2014-7-15 20:28 编辑

到官网(http://www.opendesign.com/)去下载了最新的Teigha Viewer +上SDK组合在一起 发现是可用的 。。。

DwgView类的InitializeGraphics函数这里要改下要
using (var module = (TGs.GsModule)TRx.SystemObjects.DynamicLinker.LoadModule("WinBitmap.txv", false, true))


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2014-7-15 21:30 | 显示全部楼层
第三方插件;
集成来自 Siemens PLM软件的 D-Cubed 2D DCM(2D标注约束管理器 )

对这个很感兴趣哈,低版本CAD做标准件裤的希望
发表于 2014-7-23 00:58 | 显示全部楼层
太需要这个东西了,资料太少了。谢谢雪山飞狐_lzh
发表于 2014-8-3 11:43 | 显示全部楼层
有没有更多参考资料呢。
 楼主| 发表于 2014-8-4 20:48 | 显示全部楼层
Teigha的代码基本和.Net二次开发的没有很大区别
发表于 2014-8-4 22:31 | 显示全部楼层
谢谢,终于看到4.0的了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-25 21:42 , Processed in 0.656175 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表