Plot issues with VBA

Plot issues with VBA

Jonathan3891
Advisor Advisor
1,238 Views
3 Replies
Message 1 of 4

Plot issues with VBA

Jonathan3891
Advisor
Advisor

Hey everyone.

I am working on a vba plot tool that I am having a few issues with.

I was having trouble setting the paper size and after a ton of searching I found the "blad" section of coding which seems to be working with the exception of the sheet style. Maybe it should be plotstyle?

My other main issue is that when I run this module, it takes 30 seconds or so before it prints. What is causing the delay? I have no loops or arrays, so I'm not sure why its taking so long.

 

Public Sub Plot_11x17()
Dim PntrName As String
Dim CTBhalf As String
Dim blad As AcadLayout

PntrName = UserForm1.PntrName.Value
CTBhalf = UserForm1.CTBhalf.Value

'Set Values
Set blad = ThisDrawing.Layouts.Item(layout1)
ThisDrawing.ActiveLayout = blad
blad.ConfigName = PntrName
blad.CanonicalMediaName = "11x17"
blad.PlotType = acExtents
blad.CenterPlot = True
blad.StandardScale = acScaleToFit
blad.ScaleLineweights = False
blad.StyleSheet = CTBhalf '<<<<<<<<<<<<<<<<<<< not working!!!!!!!!!!
blad.PlotWithPlotStyles = False
blad.PlotWithLineweights = fasle

'Set Number of Copies
ThisDrawing.Plot.NumberOfCopies = 1

'Initiate Plot
ThisDrawing.Plot.PlotToDevice

End Sub

Jonathan Norton
Blog | Linkedin
0 Likes
1,239 Views
3 Replies
Replies (3)
Message 2 of 4

Ed__Jobe
Mentor
Mentor

You need to add the file extension, e.g. CTBhalf.ctb. The delay could be caused by acad searching all the paths looking for the file.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 3 of 4

Jonathan3891
Advisor
Advisor

Thanks for your reply Ed.

 

 

I have a userform that uses "GetPlotStyleTableNames" to get the ctb names and the name is passed to the module with

CTBhalf = UserForm1.CTBhalf.Value

 

So in theory the code should be reading "CMS_b_black.ctb", correct?


Jonathan Norton
Blog | Linkedin
0 Likes
Message 4 of 4

Ed__Jobe
Mentor
Mentor

Easy to find out. Set a breakpoint and step through the code and inspect the variable.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature