bill165 发表于 2015-7-28 17:56:21

C#开发CAD这么弱吗?zoom都这么难解决

C#开发CAD这么弱吗?zoom都这么难解决
大家是怎么解决的?

hnzgs 发表于 2015-8-10 11:06:09

Autodesk.AutoCAD.Internal.Utils.ZoomAuto(1, 1, 1, 1, 1)

tiancao100 发表于 2024-2-1 15:54:28

guohq 发表于 2015-8-1 15:41
_
    Private Shared Function acedCmd(ByVal rbp As IntPtr) As Integer
         


    Public Shared Sub ZoomAll()
      Dim res As New ResultBuffer From {
            New TypedValue(Autodesk.AutoCAD.Runtime.LispDataType.Text, "._ZOOM"),
            New TypedValue(Autodesk.AutoCAD.Runtime.LispDataType.Text, "_A")
      }
      acedCmd(res.UnmanagedObject)
    End Sub
    <DllImport("accore.dll", EntryPoint:="acedCmd", CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.Cdecl)>
    Private Shared Function acedCmd(ByVal rbp As IntPtr) As Integer
    End Function

为何我这个zoomall没反应

guohq 发表于 2024-2-5 08:09:08

tiancao100 发表于 2024-2-1 15:54
Public Shared Sub ZoomAll()
      Dim res As New ResultBuffer From {
            New Typed ...

你用的CAD哪个版本?

sxpd 发表于 2015-8-1 08:47:08

可以调用com库的zoom×××

guohq 发表于 2015-8-1 15:41:18

<DllImport("acad.exe", EntryPoint:="acedCmd", CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.Cdecl)> _
    Private Shared Function acedCmd(ByVal rbp As IntPtr) As Integer
         
    End Function


    Public Shared Sub ZoomWindow(ByVal Point1 As Point3d, ByVal Point2 As Point3d)

      Dim res As New ResultBuffer
      res.Add(New TypedValue(Autodesk.AutoCAD.Runtime.LispDataType.Text, "._ZOOM"))
      res.Add(New TypedValue(Autodesk.AutoCAD.Runtime.LispDataType.Text, "_W"))
      res.Add(New TypedValue(Autodesk.AutoCAD.Runtime.LispDataType.Point3d, Point1))
      res.Add(New TypedValue(Autodesk.AutoCAD.Runtime.LispDataType.Point3d, Point2))
      acedCmd(res.UnmanagedObject)
    End Sub

平台调用,很方便!!

Real_King 发表于 2015-9-6 20:46:07

guohq 发表于 2015-8-1 15:41 static/image/common/back.gif
_
    Private Shared Function acedCmd(ByVal rbp As IntPtr) As Integer
         


guohp仁兄能否用C#改写下?感谢,感觉用.NET的ZE不准确,我都是通过com的

guohq 发表于 2015-9-9 10:37:36


private static extern int acedCmd(IntPtr rbp);




public static void ZoomWindow(Point3d Point1, Point3d Point2)
{
        ResultBuffer res = new ResultBuffer();
        res.Add(new TypedValue(Autodesk.AutoCAD.Runtime.LispDataType.Text, "._ZOOM"));
        res.Add(new TypedValue(Autodesk.AutoCAD.Runtime.LispDataType.Text, "_W"));
        res.Add(new TypedValue(Autodesk.AutoCAD.Runtime.LispDataType.Point3d, Point1));
        res.Add(new TypedValue(Autodesk.AutoCAD.Runtime.LispDataType.Point3d, Point2));
        acedCmd(res.UnmanagedObject);
}

革天明 发表于 2015-10-6 18:17:12

guohq 发表于 2015-9-9 10:37 static/image/common/back.gif


Autodesk.AutoCAD.Runtime.LispDataType.Text

这介.net 4.0的功能吧?
.net 2.0显示没有这个

cdinten 发表于 2015-10-8 09:07:59

这个……。NET相比较之前的ARX还是有很多地方没有完善的,如果不将之前的ARX打包,则自己实现起来就比较麻烦了

cairunbin 发表于 2016-1-13 21:10:54

C#没有这么弱。
Zoom,需要对底层的视口记录操作,如下面代码,获取到ViewTableRecord 对象后,对其CenterPoint、Width、Height属性进行设计即可。                        Autodesk.AutoCAD.ApplicationServices.Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
                        Editor editor = doc.Editor;
                        ViewTableRecord viewTableRecord = editor.GetCurrentView();
                        try
                        {
                                viewTableRecord.CenterPoint = center;
                                viewTableRecord.Height = (extents.MaxPoint.Y - extents.MinPoint.Y);
                                viewTableRecord.Width = (extents.MaxPoint.X - extents.MinPoint.X);
                                editor.SetCurrentView(viewTableRecord);
                                Autodesk.AutoCAD.ApplicationServices.Application.UpdateScreen();
                        }

125plus225 发表于 2016-3-1 17:08:27

cairunbin 发表于 2016-1-13 21:10 static/image/common/back.gif
C#没有这么弱。
Zoom,需要对底层的视口记录操作,如下面代码,获取到ViewTableRecord 对象后,对其Center ...

cad2006呢,Editor貌似没有GetCurrentView()和SetCurrentView()方法啊
页: [1] 2
查看完整版本: C#开发CAD这么弱吗?zoom都这么难解决