乐筑天下

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

[编程交流] 用vba更改阴影图

[复制链接]

14

主题

40

帖子

26

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 15:09:15 | 显示全部楼层 |阅读模式
大家好
 
我创建了一个布局,插入了一个drawingborder和一个视口。我还更改了视口中的视图。对于反视口,我还想做一件事;将着色打印设置为“隐藏”。
 
这是vba;
 
  1. Dim newPViewport As AcadPViewport
  2.    Dim center0(0 To 2) As Double
  3.    Dim center1(0 To 2) As Double
  4.    Dim center2(0 To 2) As Double
  5.    Dim center3(0 To 2) As Double
  6.    Dim width As Double
  7.    Dim height As Double
  8.            center0(0) = -110: center0(1) = 115.25: center0(2) = 0
  9.            center1(0) = -110: center1(1) = 229.75: center1(2) = 0
  10.            center2(0) = -310: center2(1) = 115.25: center2(2) = 0
  11.            center3(0) = -310: center3(1) = 229.75: center3(2) = 0
  12.            width = 200
  13.            height = 114.5
  14.    DWG_NameFull = ThisDrawing.Name
  15.    DWG_Name = Replace(DWG_NameFull, ".dwg", "")
  16.    ThisDrawing.ActiveSpace = acPaperSpace
  17.    ThisDrawing.SendCommand ("layout" & vbCr & "r" & vbCr & vbCr & DWG_Name & vbCr)
  18.    Dim Logo As AcadBlockReference
  19.    Dim Kader As AcadBlockReference
  20.    Dim DynProps As Variant
  21.    Dim Variabelen As AcadDynamicBlockReferenceProperty
  22.    Dim I As Integer
  23.    Dim insertionPnt(0 To 2) As Double
  24.    insertionPnt(0) = 0#: insertionPnt(1) = 0#: insertionPnt(2) = 0#
  25.    Set Logo = ThisDrawing.PaperSpace.InsertBlock(insertionPnt, "GEALOGO", 1#, 1#, 1#, 0#)
  26.    Set Kader = ThisDrawing.PaperSpace.InsertBlock(insertionPnt, "KADER", 1#, 1#, 1#, 0#)
  27.    If Kader.IsDynamicBlock Then
  28.        DynProps = Kader.GetDynamicBlockProperties
  29.        For I = 0 To UBound(DynProps)
  30.            Set Variabelen = DynProps(I)
  31.            If Variabelen.Value = "A3" Then
  32.                Variabelen.Value = Formaat
  33.                Exit For
  34.            End If
  35.        Next
  36.    End If
  37.    ThisDrawing.ActiveLayout.RefreshPlotDeviceInfo
  38.    ThisDrawing.ActiveLayout.ConfigName = "DWFx ePlot.pc3"
  39.    ThisDrawing.ActiveLayout.StyleSheet = "GEA-kleur-diktes.ctb"
  40.    ThisDrawing.ActiveLayout.PlotType = acExtents
  41.    ThisDrawing.ActiveLayout.CenterPlot = True
  42.    ThisDrawing.ActiveLayout.StandardScale = acScaleToFit
  43.    AutoCAD.Update
  44.    curpapersizes = ThisDrawing.PaperSpace.Layout.GetCanonicalMediaNames()
  45.    ThisDrawing.Regen (acActiveViewport)
  46.    Dim G_sht_frm As String
  47.    G_sht_frm = "UserDefinedMetric (420.00 x 297.00MM)"
  48.    ThisDrawing.ActiveLayout.CanonicalMediaName = G_sht_frm
  49.    ThisDrawing.ActiveLayout.PlotRotation = plotrot
  50.    ThisDrawing.Regen (acAllViewports)
  51.    AutoCAD.ZoomAll
  52.    Dim Layer As AcadLayer
  53.    Set Layer = ThisDrawing.Layers.Add("Viewport")
  54.    Layer.color = acMagenta
  55.    Layer.Plottable = False
  56.    ThisDrawing.ActiveLayer = ThisDrawing.Layers.Item("Viewport")
  57. Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center0, width, height)
  58.            newPViewport.Display (True)
  59.            [color=red]newPViewport.VisualStyle = 3[/color]
  60.            ThisDrawing.MSpace = True
  61.            ThisDrawing.ActivePViewport = newPViewport
  62.            ThisDrawing.SendCommand ("-view" & vbCr & "Right" & vbCr)
  63.            ThisDrawing.SendCommand ("pspace" & vbCr)
  64. ThisDrawing.Regen acAllViewports
  65.    Call VBA.Unload(Me)

 
如您所见,我已将添加的视口视觉样式设置为3(隐藏?)。标准值为1(如图所示?)。在vba中,本地更改为3。但在autoCAD中,着色打印仍然是“显示的”。
 
在autoCAD的VBA帮助下,我无法理解螺旋的含义并将其应用于我的问题。
 
谁能告诉我为什么阴影图没有改变,怎么做?
 
thnx很多
回复

使用道具 举报

14

主题

40

帖子

26

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 15:20:26 | 显示全部楼层
现在我得到了以下代码:
  1. Dim Layer As AcadLayer
  2.    Set Layer = ThisDrawing.Layers.Add("Viewport")
  3.    Layer.color = acMagenta
  4.    Layer.Plottable = False
  5.    ThisDrawing.ActiveLayer = ThisDrawing.Layers.Item("Viewport")
  6.        Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center0, width, height)
  7.            newPViewport.Display (True)
  8.            newPViewport.VisualStyle = 3
  9.            ThisDrawing.MSpace = True
  10.            ThisDrawing.ActivePViewport = newPViewport
  11.            ThisDrawing.SendCommand ("-view" & vbCr & "Right" & vbCr)
  12.            VBA.DoEvents
  13.            'ThisDrawing.ActiveSpace = acPaperSpace
  14.        Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center1, width, height)
  15.            newPViewport.Display (True)
  16.            newPViewport.VisualStyle = 3
  17.            ThisDrawing.MSpace = True
  18.            ThisDrawing.ActivePViewport = newPViewport
  19.            ThisDrawing.SendCommand ("-view" & vbCr & "SW" & vbCr)
  20.            VBA.DoEvents
  21.            'ThisDrawing.ActiveSpace = acPaperSpace
  22.        Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center2, width, height)
  23.            newPViewport.Display (True)
  24.            newPViewport.VisualStyle = 3
  25.            ThisDrawing.MSpace = True
  26.            ThisDrawing.ActivePViewport = newPViewport
  27.            ThisDrawing.SendCommand ("-view" & vbCr & "Front" & vbCr)
  28.            VBA.DoEvents
  29.            'ThisDrawing.ActiveSpace = acPaperSpace
  30.        Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center3, width, height)
  31.            newPViewport.Display (True)
  32.            newPViewport.VisualStyle = 3
  33.            ThisDrawing.MSpace = True
  34.            ThisDrawing.ActivePViewport = newPViewport
  35.            ThisDrawing.SendCommand ("-view" & vbCr & "Top" & vbCr)
  36.            VBA.DoEvents
  37.            'ThisDrawing.ActiveSpace = acPaperSpace
  38.       ThisDrawing.SendCommand ("pspace" & vbCr)

 
如果我用F8开始代码。它工作完美。如果我使用F5。它跳过了所有命令:“ThisDrawing.SendCommand(“-view”&vbCr&“xxx”&vbCr)”,当他完成后,它会执行这些命令。所以我看到最后一个视口变为“Right”“SW”“Front”和“TOP”
 
怎么会??我该怎么修?
 
我还有一个问题没有回答
 
thnx!
回复

使用道具 举报

10

主题

973

帖子

909

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 15:33:33 | 显示全部楼层
VBA的“SendCommand”往往有问题——因此最好设置例程:
 
  1. Sub GenViews()
  2. Dim center0(0 To 2) As Double
  3. Dim center1(0 To 2) As Double
  4. Dim center2(0 To 2) As Double
  5. Dim center3(0 To 2) As Double
  6. Dim width As Double
  7. Dim height As Double
  8. Dim Layer As AcadLayer
  9. Dim vDirection(0 To 2) As Double
  10. Dim newPViewport As AcadPViewport
  11.   center0(0) = 110: center0(1) = 115.25: center0(2) = 0
  12.   center1(0) = 110: center1(1) = 229.75: center1(2) = 0
  13.   center2(0) = 310: center2(1) = 115.25: center2(2) = 0
  14.   center3(0) = 310: center3(1) = 229.75: center3(2) = 0
  15.   width = 200
  16.   height = 114.5
  17.    Set Layer = ThisDrawing.Layers.Add("Viewport")
  18.    Layer.color = acMagenta
  19.    Layer.Plottable = False
  20.    ThisDrawing.ActiveLayer = ThisDrawing.Layers.Item("Viewport")
  21.        Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center0, width, height)
  22.            newPViewport.ShadePlot = acShadePlotRendered
  23.            vDirection(0) = 1#
  24.            vDirection(1) = 0#
  25.            vDirection(2) = 0#
  26.            newPViewport.Direction = vDirection
  27.            newPViewport.Display True
  28.            ThisDrawing.MSpace = True
  29.            ZoomExtents
  30.        Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center1, width, height)
  31.            newPViewport.ShadePlot = acShadePlotRendered
  32.            vDirection(0) = -1#
  33.            vDirection(1) = -1#
  34.            vDirection(2) = 1#
  35.            newPViewport.Direction = vDirection
  36.            newPViewport.Display True
  37.            ThisDrawing.MSpace = True
  38.            ZoomExtents
  39.        Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center2, width, height)
  40.            newPViewport.ShadePlot = acShadePlotRendered
  41.            vDirection(0) = 0#
  42.            vDirection(1) = -1#
  43.            vDirection(2) = 0#
  44.            newPViewport.Direction = vDirection
  45.            newPViewport.Display True
  46.            ThisDrawing.MSpace = True
  47.            ZoomExtents
  48.        Set newPViewport = ThisDrawing.PaperSpace.AddPViewport(center3, width, height)
  49.            newPViewport.ShadePlot = acShadePlotRendered
  50.            vDirection(0) = 0#
  51.            vDirection(1) = 0#
  52.            vDirection(2) = 1#
  53.            newPViewport.Direction = vDirection
  54.            newPViewport.Display True
  55.            ThisDrawing.MSpace = True
  56.            ZoomExtents
  57.            ThisDrawing.MSpace = False
  58. End Sub
回复

使用道具 举报

14

主题

40

帖子

26

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 15:42:49 | 显示全部楼层
隐马尔可夫模型。。。我有几分钟的时间再查一下。谢谢
 
毫无疑问,vDirection(0)、(1)和(2)用于将视图设置为TOP、SW、FRONT等?这在数字中是如何工作的?
回复

使用道具 举报

10

主题

973

帖子

909

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 15:55:07 | 显示全部楼层
这些数字的工作方式与AutoCAD的VPOINT命令相同。也就是说,数字vDirection(0)、(1)和(2)分别对应于WCS x、y和z。因此,例如,俯视图可以描述为从与向量0,0,1到0,0,0对齐的视图中查看模型
回复

使用道具 举报

1

主题

56

帖子

80

银币

初来乍到

Rank: 1

铜币
1
发表于 2022-7-6 16:04:11 | 显示全部楼层
我现在没有时间复习这段代码,但这似乎与我遇到的问题类似-只是在Modelspace中设置shademode-(我使用sendcommand)你认为这可以将Modelspace用作当前视口吗?
回复

使用道具 举报

14

主题

40

帖子

26

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 16:13:56 | 显示全部楼层
我认为也是这样
 
 
ps。
我使用“newPViewport.ShadePlot=acShadePlotHidden”将其设置为隐藏而非三维隐藏(acShadePlotRendered)
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 19:30 , Processed in 0.737637 second(s), 67 queries .

© 2020-2025 乐筑天下

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