Add function "Plot Style Table" for windown form

Add function "Plot Style Table" for windown form

traiduong014969
Collaborator Collaborator
402 Views
5 Replies
Message 1 of 6

Add function "Plot Style Table" for windown form

traiduong014969
Collaborator
Collaborator

Hi, 

Have good day!

Currently, In my form, I'm creating a custom table to print DWG TO PDF with c#. In that I want to add function "Plot style table" to custom my form as snapshot below

However, I don't know code to make it into my code. So someone can help me a for that

Thank you!

traiduong014969_0-1679672375214.png

traiduong014969_1-1679672528600.png

 

 

0 Likes
403 Views
5 Replies
Replies (5)
Message 2 of 6

Ed__Jobe
Mentor
Mentor

Before you spend a lot of time on that solution, you might want to know that Bluebeam Revu has an AutoCAD plugin that stores plot settings and then can generate a pdf with a single click based on the saved settings. You save your settings using the second button, then plot with the first button.

BB plugin.png

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 6

traiduong014969
Collaborator
Collaborator
Yes, this is first step for my practice with make custom function in cad to window form. In that, I can customize for my idea. I need test OK a function, so I can easily make more similar function. So you can make for me code to my suggestion above?
0 Likes
Message 4 of 6

norman.yuan
Mentor
Mentor

The plot styles listed in "Plot" dialog box is just the plot style file names (*.ctb) in the AutoCAD's support folder:

 

C:\Users\[user name]\AppData\Roaming\Autodesk\[AutoCAD Version]\enu\Plotters\Plot Styles

 

So, you only need to reach that folder and collect all the *.ctb file names as a string List/Array and use it to populate the dropdown list on your UI.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 6

traiduong014969
Collaborator
Collaborator
Great idea, however I don't know how to way make it, if you can, you can make for example code via your idea for me
0 Likes
Message 6 of 6

norman.yuan
Mentor
Mentor

The code should be something like

private static List<string> GetPlotStyleList()
        {
            var folder = $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\Autodesk\\C3D 2021\\enu\\Plotters\\Plot Styles";
            var files = System.IO.Directory.GetFiles(folder, "*.ctb");

            return (from f in files select System.IO.Path.GetFileName(f)).ToList();
        }

 

As you can see, the folder path would be different, depending on the AutoCAD version/vertical product that you are running. For simplicity, I hard coded here as "C3D 2021". You may have to decide the running AutoCAD's version, production name to make this simple code can be used with different version/product of AutoCAD, but since your question is about how to get plot style list, this gives you an idea of how.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes