todi 发表于 2022-7-6 22:17:34

[帮助]plot meth的问题

'Begin plot proccess
Do While iCurrPage <= iEndPage
For i = 0 To lstPages.Size - 1
        'Retrieves an page object for plot data aquisition
        Set area = lstPages.getListItem(Int(i))
       
        If area.PageNumber = iCurrPage Then
                'Marks the plot area based on calculated element coordinates
                Call AcadApp.ActiveDocument.ActiveLayout.SetWindowToPlot(area.StartPosition, area.EndPosition)
                'Plot the marked area
                Call AcadApp.ActiveDocument.ActiveLayout.GetWindowToPlot(area.StartPosition, area.EndPosition)
                'Configures the marked area for window plot type
                AcadApp.ActiveDocument.ActiveLayout.PlotType = acWindow
                'Scales the area of impression to fit the page
                AcadApp.ActiveDocument.ModelSpace.Layout.StandardScale = acScaleToFit
                'Number of copies for one page
                AcadApp.ActiveDocument.Plot.NumberOfCopies = iQntCopy
                'Plot
                Call AcadApp.ActiveDocument.Plot.PlotToDevice
                'Resume if an error occurs
                On Error Resume Next
                'Increment the page counter
                iCurrPage = iCurrPage + 1
        End If
Next i
Loop

iDeeW 发表于 2022-7-6 22:22:58

这是LUA吗?看起来很像,但有点不同。

Tuns 发表于 2022-7-6 22:26:55

不这是Visual Basic for Applications(VBA)

iDeeW 发表于 2022-7-6 22:31:09

哦对不起,我错了。我能想到的唯一一件可能与他的错误是他设置I=0,最后他将iCurrPage=iCurrPage+1,当他第一次没有将其定义为iCurrPage时。

Public Sub PlotPreview()
If MsgBox("Preview", vbYesNo) = vbYes Then
       ThisDrawing.Plot.DisplayPlotPreview acFullPreview
   Else
       ThisDrawing.Plot.DisplayPlotPreview acPartialPreview
   End If
End Sub

应该是
For i = 0 To lstPages.Size - 1
至少在LUA是这样的。我只是基于这一点来思考,因为它们看起来很相似,我想它们的功能差不多。不过我可能错了。。。

Tuns 发表于 2022-7-6 22:36:01

你的意思是,可以使用LUA自动化AutoCAD吗?
你能帮我发一个示例代码吗。。。

iDeeW 发表于 2022-7-6 22:39:29

For iCurrPage = 0 To lstPages.Size - 1
应该将其更改为
iCurrPage = iCurrPage + 1
因为一开始你叫它“我”。
我希望。。。我会尽力的。。。我相信你可以在21世纪的时候做这件事,但如果可以的话,它看起来几乎和你已经拥有的一模一样。
i = i + 1
大概是这样
Public Sub PlotPreview()
If MsgBox("Preview", vbYesNo) = vbYes Then
       ThisDrawing.Plot.DisplayPlotPreview acFullPreview
   Else
       ThisDrawing.Plot.DisplayPlotPreview acPartialPreview
   End If
End Sub
在卢阿。如果我用正确的方式做的话,会有更多的内容,但既然没关系,我只是给了你一个想法。

Tuns 发表于 2022-7-6 22:47:31

我可能错了,但我只是注意到了这一点。告诉我它是否有效。
Public Sub PlotPreview()
If MsgBox("Preview", vbYesNo) = vbYes Then
       ThisDrawing
       Plot
       DisplayPlotPreview
       acFullPreview
   Else
       ThisDrawing
       Plot
       DisplayPlotPreview
       acPartialPreview
   End
End
我认为你把if-then语句放错了地方,所以当你把“end if”放在末尾时,它没有if-then语句。我说错了吗?因为有时取决于你使用的脚本语言,它去哪里都无关紧要。

Tuns 发表于 2022-7-6 22:48:40

这是如何在VB中执行if条件。。。没什么不对的。。。

iDeeW 发表于 2022-7-6 22:53:32

if-then语句与它的end函数不在同一个位置,有什么原因吗?我很好奇为什么会这样。你知道吗?如果不是,我不介意。

Tuns 发表于 2022-7-6 22:57:02

http://www.techonthenet.com/excel/formulas/if_then.php
页: [1] 2
查看完整版本: [帮助]plot meth的问题