乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 137|回复: 8

VBA绘图

[复制链接]

12

主题

64

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
112
发表于 2006-10-12 17:31:11 | 显示全部楼层 |阅读模式
正在开发另一个QuickPlot程序。本人'我对a没有任何问题;SendCommand“;场景中,基本上通过“通过”命令行通过所有提示;vbCr;。效果很好。但现在他们(用户)希望能够绘制模型空间布局的窗口部分。这里是#039;这就是我'我们得到了:旧方法:
  1. Sub plt_18x24()
  2. Call AcadApplication.RunMacro("Q:\Std\ACAD\Support\Lisp\drafting_db.dvb!plot_counter")
  3. ThisDrawing.SendCommand "-plot" & vbCr & "y" & vbCr & "Model" & vbCr & "Oce TDS600 3.x.pc3" & vbCr & "ARCH expand C (24.00 x 18.00 Inches)" & vbCr & "inches" & vbCr & "Landscape" & vbCr & "no" & vbCr & "extents" & vbCr & "fit" & vbCr & "Center" & vbCr & "yes" & vbCr & "comed36x24.ctb" & vbCr & "yes" & vbCr & "n" & vbCr & vbCr & vbCr & vbCr
  4. End Sub

此处#039;这就是我'我正在努力发展:
  1. Sub qplot_d_color()
  2. Call AcadApplication.RunMacro("Q:\Std\ACAD\Support\Lisp\drafting_db.dvb!plot_counter")
  3.     Dim point1 As Variant, point2 As Variant
  4.     point1 = ThisDrawing.Utility.GetPoint(, "Click the lower-left of the window to plot.")
  5.     ReDim Preserve point1(0 To 1)
  6.     point2 = ThisDrawing.Utility.GetPoint(, "Click the upper-right of the window to plot.")
  7.     ReDim Preserve point2(0 To 1)
  8.     ThisDrawing.ActiveLayout.SetWindowToPlot point1, point2
  9.     ThisDrawing.ActiveLayout.GetWindowToPlot point1, point2
  10. ThisDrawing.SendCommand "-plot" & vbCr & "y" & vbCr & "Model" & vbCr & "DesignJet 500.pc3" & vbCr & "ARCH D (36.00 x 24.00 Inches)" & vbCr & "inches" & vbCr & "Landscape" & vbCr & "no" & vbCr & "window" & vbCr & vbCr & vbCr & "fit" & vbCr & "Center" & vbCr & "yes" & vbCr & "C-D-E_Color.ctb" & vbCr & "yes" & vbCr & "n" & vbCr & vbCr & vbCr & vbCr
  11. End Sub

工作正常,除了没有';矩形“;选择LL&你的角落。除此之外;这也有点俗气
我们非常欢迎任何改进。
回复

使用道具 举报

0

主题

5

帖子

3

银币

初来乍到

Rank: 1

铜币
7
发表于 2006-10-12 18:18:57 | 显示全部楼层
我有VBA的快速绘图例程,但不使用;一扇窗户 让我看看我能补充什么
回复

使用道具 举报

0

主题

13

帖子

6

银币

初来乍到

Rank: 1

铜币
14
发表于 2006-10-12 18:29:25 | 显示全部楼层
您可以尝试删除SendCommand,这几乎总是会给您带来问题。在VB/VBA中绘图并不简单,但它不是#039;这也不可能
这可能会让你开始。请记住我没有#039;t对此进行了测试
  1. Public Sub foo()
  2.     Dim config As AcadPlotConfiguration
  3.     Set config = ThisDrawing.PlotConfigurations(ThisDrawing.ActiveLayout.ConfigName)
  4.     config.ConfigName = "Oce TDS600 3.x.pc3"
  5.     config.CanonicalMediaName = "ARCH expand C (24.00 x 18.00 Inches)"
  6.     config.PlotType = acExtents
  7.     config.CenterPlot = True
  8.     config.StandardScale = acScaleToFit
  9.     config.RefreshPlotDeviceInfo
  10.     ThisDrawing.Plot.PlotToDevice config.ConfigName
  11.    
  12. End Sub
回复

使用道具 举报

0

主题

9

帖子

4

银币

初来乍到

Rank: 1

铜币
13
发表于 2006-10-12 18:57:48 | 显示全部楼层
感谢Cmdr,它'自从我'我能做任何与VBA相关的事情。我一直在努力解决设计问题,因此我呼吁武装起来。我很感激。
回复

使用道具 举报

0

主题

5

帖子

3

银币

初来乍到

Rank: 1

铜币
8
发表于 2006-10-12 18:58:44 | 显示全部楼层
感谢莫恩斯顿,我'明天我会公布结果。
回复

使用道具 举报

0

主题

12

帖子

4

银币

初来乍到

Rank: 1

铜币
12
发表于 2006-10-13 09:52:04 | 显示全部楼层
这是我的设置例程
  1. Option Explicit
  2. Public Sub SetupAndPlot(ByRef Plotter As String, CTB As String, SIZE As String, PSCALE As String, ROT As String)
  3.     Dim Layout As AcadLayout
  4.     On Error GoTo Err_Control
  5.     Set Layout = ThisDrawing.ActiveLayout
  6.     Layout.RefreshPlotDeviceInfo
  7.     Layout.ConfigName = Plotter    ' CALL PLOTTER
  8.     Layout.PlotType = acExtents
  9.     Layout.PlotRotation = ROT    ' CALL ROTATION
  10.     Layout.StyleSheet = CTB    ' CALL CTB FILE
  11.     Layout.PlotWithPlotStyles = True
  12.     Layout.PlotViewportBorders = False
  13.     Layout.PlotViewportsFirst = True
  14.     Layout.CanonicalMediaName = SIZE    ' CALL SIZE
  15.     Layout.PaperUnits = acInches
  16.     Layout.StandardScale = PSCALE    'CALL PSCALE
  17.     Layout.ShowPlotStyles = False
  18.     ThisDrawing.Plot.NumberOfCopies = 1
  19.     Layout.CenterPlot = True
  20.     Layout.ScaleLineweights = False
  21.     Layout.RefreshPlotDeviceInfo
  22.     ThisDrawing.Regen acAllViewports
  23.     ZoomExtents
  24.     Set Layout = Nothing
  25.     ThisDrawing.Save
  26. Exit_Here:
  27.     Exit Sub
  28. Err_Control:
  29.     Select Case Err.Number
  30.     Case "-2145320861"
  31.         MsgBox "Unable to Save Drawing- " & Err.Description
  32.     Case "-2145386493"
  33.         MsgBox "Drawing is setup for Named Plot Styles." & (Chr(13)) & (Chr(13)) & "Run CONVERTPSTYLES command", vbCritical, "Change Plot Style"
  34.     Case Else
  35.         MsgBox "Unknown Error " & Err.Number
  36.     End Select
  37. End Sub
这就是我如何调用它,并将大小、旋转、ctb等作为参数传递
  1. ' a few examples
  2. Public Sub Vendor1117()
  3.     Call SetupAndPlot("11x17Draft.pc3", "11X17-CHECKSET.ctb", "ANSI_B_(11.00_x_17.00_Inches)", acScaleToFit, ac90degrees)
  4.     ThisDrawing.Plot.PlotToDevice
  5.     ThisDrawing.Close (True)
  6. End Sub
  7. Public Sub VendorQuickPlotC()
  8.     Call SetupAndPlot("OCE DesignJet 750C.pc3", "VENDOR MEDIUM.ctb", "ARCH_expand_C_(24.00_x_18.00_Inches)", acScaleToFit, ac0degrees)
  9.     ThisDrawing.Plot.PlotToDevice
  10.     ThisDrawing.Close (True)
  11. End Sub
  12. Public Sub VendorQuickPlotD()
  13.     Call SetupAndPlot("OCE DesignJet 750C.pc3", "VENDOR MEDIUM.ctb", "ARCH_expand_D_(36.00_x_24.00_Inches)", ac1_1, ac0degrees)
  14.     ThisDrawing.Plot.PlotToDevice
  15.     ThisDrawing.Close (True)
  16. End Sub
现在我们需要做的就是生成一个窗口并将其输入。
回复

使用道具 举报

0

主题

11

帖子

7

银币

初来乍到

Rank: 1

铜币
12
发表于 2006-10-13 09:56:03 | 显示全部楼层
我找到了这个
  1. layout.GetWindowToPlot LL,UR
所以你需要做的就是将LL和UR定义为具有
  1. dim LL(0 to 2) as double
  2. dim UR(0 to 2) as double
  3. 'pseudo code getpoint LL and UR
回复

使用道具 举报

0

主题

12

帖子

7

银币

初来乍到

Rank: 1

铜币
13
发表于 2006-10-13 11:16:31 | 显示全部楼层
谢谢指挥官,今天有最后期限。在你和莫恩斯顿之间,我认为有#039;有足够的信息帮我弄清楚
快跑,快跑
缩放。。。。
回复

使用道具 举报

0

主题

13

帖子

5

银币

初来乍到

Rank: 1

铜币
16
发表于 2006-10-13 15:27:48 | 显示全部楼层
我把这件事做好了
  1. Dim LL As Variant, UR As Variant
  2.     LL = ThisDrawing.Utility.GetPoint
  3.     UR = ThisDrawing.Utility.GetPoint
  4.     ThisDrawing.ModelSpace.AddLine LL, UR
所以我能够画一条线,所以你们应该能够使用布局。GetWindowToPlot LL,UR
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-6 21:15 , Processed in 1.632586 second(s), 70 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表