C#开发CAD这么弱吗?zoom都这么难解决
C#开发CAD这么弱吗?zoom都这么难解决大家是怎么解决的? Autodesk.AutoCAD.Internal.Utils.ZoomAuto(1, 1, 1, 1, 1) 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没反应 tiancao100 发表于 2024-2-1 15:54
Public Shared Sub ZoomAll()
Dim res As New ResultBuffer From {
New Typed ...
你用的CAD哪个版本? 可以调用com库的zoom×××
<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
平台调用,很方便!! 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的
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);
}
guohq 发表于 2015-9-9 10:37 static/image/common/back.gif
Autodesk.AutoCAD.Runtime.LispDataType.Text
这介.net 4.0的功能吧?
.net 2.0显示没有这个 这个……。NET相比较之前的ARX还是有很多地方没有完善的,如果不将之前的ARX打包,则自己实现起来就比较麻烦了 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();
}
cairunbin 发表于 2016-1-13 21:10 static/image/common/back.gif
C#没有这么弱。
Zoom,需要对底层的视口记录操作,如下面代码,获取到ViewTableRecord 对象后,对其Center ...
cad2006呢,Editor貌似没有GetCurrentView()和SetCurrentView()方法啊
页:
[1]
2