Problem With Plotting Routine

Problem With Plotting Routine

Anonymous
Not applicable
473 Views
1 Reply
Message 1 of 2

Problem With Plotting Routine

Anonymous
Not applicable

Hi Guys,

 

I am trying to build a plotting script but it keeps dying in the middle.  I do not want to use the publish engine so i am using the command interface.  Here's the code.

 

 

    <CommandMethod("MB_PlotAllTabs")> _
    Public Sub MB_PlotAllTabs()
        Dim LayoutSize As Integer = 1
        Dim myTabList As SortedDictionary(Of Integer, String).ValueCollection = LayoutTabList()
        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim StartNum As Integer = New Integer
        Dim StopNum As Integer = New Integer
        Dim LinesBeforePrinterSettings As Integer = 16
        Dim PrinterINISettingLines As Integer = 7
        Dim INIValueArr(0 To 6) As String
        Dim i As Integer = 0
        Dim PlotString As String = Nothing

        StartNum = LinesBeforePrinterSettings + 1
        If LayoutSize <> 1 Then
            StartNum = StartNum + PrinterINISettingLines * LayoutSize
        End If
        StopNum = LinesBeforePrinterSettings + PrinterINISettingLines * LayoutSize
        Do Until StartNum > StopNum
            INIValueArr(i) = GetINISetting(StartNum)
            MsgBox(INIValueArr(i), MsgBoxStyle.OkOnly)
            i += 1
            StartNum += 1
        Loop

        Dim DeviceName As String = INIValueArr(0)
        Dim PaperName As String = INIValueArr(1)
        Dim PrintUnits As String = INIValueArr(2)
        Dim PrintScale As String = INIValueArr(3)
        Dim PrintOffset As String = INIValueArr(4)
        Dim PrintOrient As String = INIValueArr(5)
        Dim PrintStyle As String = INIValueArr(6)


        For Each LayoutName In myTabList
            PlotString = "-plot Yes " + LayoutName + " " + DeviceName + " " + PaperName + " " + PrintUnits + " " + PrintOrient + " No Layout " + PrintScale + " " + PrintOffset + " Yes " + PrintStyle + " Yes Yes No No No N Y"
            MsgBox(PlotString, MsgBoxStyle.OkOnly)
            acDoc.SendStringToExecute(PlotString, True, False, False)
        Next

    End Sub

 

 

It seems to be dying just before "LayoutName" in the PlotString var.   But when it gets to the msgbox and i output the string everything is populated.  Am i doing something stupidly wrong here?

 

Thanks in advance.

0 Likes
474 Views
1 Reply
Reply (1)
Message 2 of 2

fieldguy
Advisor
Advisor

Have you tried this from the command line manually?  If not, give it a try.  Set filedia = 0, and cmddia = 0, and start with "-plot".  I have an old vba script that does this but it sends lines 1 at a time, like:

ThisDrawing.SendCommand "-PLOT" & vbCr

ThisDrawing.SendCommand "yes" & vbCr

In your example, that would be:

acDoc.SendStringToExecute("-plot", etc

I have converted this VBA to .net and while much more verbose, I prefer the managed api methods and publish engine.  My users appreciate the info I have added to plotprogressdialog.

The converted "plot" solution has been discussed in this forum and there is a good example here: http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html

under "Define layouts and plot".  

0 Likes