Plot Autocad API .net or vba

Plot Autocad API .net or vba

Anonymous
Not applicable
4,144 Views
5 Replies
Message 1 of 6

Plot Autocad API .net or vba

Anonymous
Not applicable

Hello community is there a way to convert my dwg to png? 
I need to do it programmatically and in certain dimensions.
The best way i found it easier is through plot in Autocad. I am aware of the pngout command.


is there a way to do this conversion in Autocad with certain dimesions and programmatically?

 

0 Likes
Accepted solutions (1)
4,145 Views
5 Replies
Replies (5)
Message 2 of 6

steven-g
Mentor
Mentor

This forum is for Autocad LT and if that is what you use there is no .NET or VBA functionality in LT if you need that for full Autocad then there is a dedicated forum here

0 Likes
Message 3 of 6

norman.yuan
Mentor
Mentor
Accepted solution

You can either use AutoCAD .NET API, or COM API /AutoCAD VBA plot drawing programmatically,using the "PublishToWeb PNG.pc3" as plotting device.

 

For example, this simple code sample plot the active layout to a *.png file:

 

Option Explicit

Public Sub PrintToPng()

    Dim pngFile As String
    
    pngFile = "C:\Temp\Test.png"
    
    Dim layout As AcadLayout
    Set layout = ThisDrawing.ActiveLayout
    
    layout.ConfigName = "PublishToWeb PNG.pc3"
    
    
    Dim result As Boolean
        
    result = ThisDrawing.Plot.PlotToFile(pngFile)
    
    If result Then
        MsgBox "Plotting to PNG file succeeded."
    Else
        MsgBox "Plotting to PNG file failed."
    End If

End Sub

It is pretty simple, if the active layout's plot configuration is properly set (paper size, plot scale...). Of course, you can also programmatically set up plotting configuration to the layout your want to plot before the plotting is actually done.

 

With AutoCAD .NET API, you may have event more controls on how  the plotting is done. 

 

Programmatic plotting is one of most discussed topics on AutoCAD customization programming. For using COM API to plot, you can search this forum, or browse AutoCAD VBA help document for details and sample code; for using AutoCAD .NET API, you can search the .NET forum and online AutoCAD developer guide. 

 

Without knowing your programming knowledge/skill on AutoCAD, I am going into more details. When you actually run into coding issue, feel free to post your code and ask comments/advises.

Norman Yuan

Drive CAD With Code

EESignature

Message 4 of 6

Anonymous
Not applicable

This works perfectly. Now i can customize my settings and this all i need. 
Furthermore you say there are more like these in the forums. Maybe i am blind. I must say i am new to Autocad.

I do not seem to find. You are the first to give me a clear answer.

0 Likes
Message 5 of 6

Anonymous
Not applicable

I am sorry but the title of the block is visual basic customization. I realise there is a .net. But I would accept both solutions. I guess i ll  edit my title for vba only.

0 Likes
Message 6 of 6

Anonymous
Not applicable

Do you have a way to batch plot?

You see if you go to this forum you will see the autocad code that i wrote. 

I have a problem with the plot because i want to be able to do this for more than one drawing.

Do you have any idea?

0 Likes