.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Add plot custom paper size

23 REPLIES 23
Reply
Message 1 of 24
lilacgirl1224
3252 Views, 23 Replies

Add plot custom paper size

Is it possible to add a new custom paper size in plot configuration (PublishToWeb JPG.pc3) using C#?
Thanks
23 REPLIES 23
Message 2 of 24

Hello everyone,

I'm also interested in this topic, someone has found a solution or same input to start? I need a simple C# code to add a custom paper size on PublishToWeb JPG.pc3 printer.

 

Thanks

 

Message 3 of 24
583408432
in reply to: lilacgirl1224

I also encountered the same problem.

 

Message 4 of 24
norman.yuan
in reply to: 583408432

I believe that there is neither .NET API nor COM API available to manipulate paper size defined in *.pc3.

Message 5 of 24
AubelecBE
in reply to: norman.yuan

I like to know too.

but now i insert manaly paper in the pc3 and i distribute the pc3. not very accurate but work for now. (I use the DWG to PDF.pc3)

 

Message 6 of 24
Ron_M
in reply to: lilacgirl1224

I agree with Norman.  My office plots using all custom .pc3 files created by me and used by my .net application.  In my troubles getting that to work I didn't find a way to code different configurations of .pc3 files.  Instead I use a custom .pc3 file for each plot configuration possible.  It may seem like a lot but they are not difficult to make and it allows me to use explicit settings per plot instead.

Message 7 of 24
Keith.Brown
in reply to: Ron_M

This might have some possibilities.

 

https://github.com/Allockse/PiaNO

Message 8 of 24
583408432
in reply to: Keith.Brown

It looks pretty cool!

But need take time to study it.

Anyway, thank you very much!

Message 9 of 24
Ron_M
in reply to: Keith.Brown

Thanks for the new source Keith. 

Message 10 of 24
allockse
in reply to: Keith.Brown

I'm the author of the PiaNO plot configuration API.  Just wanted to swing by and let you guys know I'd be happy to answer questions and provide further development if there's something currently not supported.  I haven't gotten a chance to really use it much after pushing the project online, however I'm happy to help and answer any questions you might have.  Also, I haven't tested adding in a new papersize node yet, but theoretically there shouldn't be anything preventing it.  I might play around with this later on in the week if I get time.

 

Regards,

Parrish 

Message 11 of 24
khoa.ho
in reply to: allockse

Hi Parrish, welcome to your first post in this forum. I've just forked your project on my GitHub and tested it works! I can read a given pc3 file to get info (media name, sizes...), and write to another pc3 file. It seems your project solved the problem of using .NET to manipulate .pc3 files. Thank you for your interesting project!

 

Khoa

 

Message 12 of 24
AubelecBE
in reply to: allockse

hi thanks for this. but have you sample of code for using the piano.dll ?

i am not very expérimented with this.

 

 

Message 13 of 24
SENL1362
in reply to: AubelecBE

Second that, this is what i came up with, but failed to retrieve actual values.

 

using PiaNO;
using PiaNO.Plot;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string pc3Pathname=@"c:\temp\DWG To PDF.pc3";
            var pc3 = new PlotterConfiguration();
            pc3.Read(pc3Pathname);
            PiaHeader ph = pc3.Header;
            PiaType pt = ph.PiaType;
            Console.WriteLine("PiaType=={0} for:{1}", Enum.GetName(typeof(PiaType), pt),pc3.FileName);
            foreach (PiaNode a in pc3)
            {
                string aNodeName = a.ToString();
                Console.WriteLine("PiaNode=={0}", aNodeName);
                if (aNodeName == "media")
                {
                    var m = pc3["media"];
                    //?HowToGet values?
                }
                foreach (PiaNode b in a)
                {
                    string bNodeName = b.ToString();
                    Console.WriteLine("\tPiaNode=={0}", bNodeName);
                    //?HowToGet values?
                }
            }
        }
    }
}

 

Message 14 of 24
SENL1362
in reply to: khoa.ho

can you post a simple sample
Message 15 of 24
allockse
in reply to: SENL1362

SENL1362, thanks for trying it out.  So in a fully completed API, the PlotterConfiguration class would have a media property/collection that one would be able to set directly.  If I remember correctly, adding a custom size would require a PMP file linked to the PC3, which would need to be taken care of automatically as well.  I also need to experiment more on how to best create a Media class, but I just haven't had time to test this in detail.  However knowing that all of this wouldn't be complete up front I made sure to expose the all of the data via the node structure.  That way one could still add in values to sub-nodes manually and have it function correctly.  All this to say that I don't have a great sample to post yet dealing with media specifically.  On the upside, the heavy lifting of reading/writing these files is done for the most part, so everything else should be fairly easy.

 

Ideally we'd have something that looks like this:

 

var filePath= @"C:\PlotTesting\Test.pc3"
var plotConfig = new PlotterConfiguration(filePath)

var newSize = new PC3Media
{
    Name = ANSI B (17.00 x 11.00 Inches),
    Bounds = new Bounds(17, 11),
PrintableBounds = new Bounds(16.54, 9.60),     Landscape = True }; plotConfig.Media = newSize; plotConfig.Write();

 

However since none of the media classes are implemented or supported yet it's going to be a lot uglier in the meantime.  Here's what the inner data of a media node currently looks like:

 

selection_method=2
type="
dm_orientation=1
actual_printable_bounds_llx=5.7937498093 (    P,PL%T 8_0)
actual_printable_bounds_lly=17.793750763 (    0#/+,4"%9@)
actual_printable_bounds_urx=273.60623169 (    (+,9<4"T7@)
actual_printable_bounds_ury=198.10624695 (    8&;#:$ <30)
number_of_copies=1
size{
 name="ANSI_A_(11.00_x_8.50_Inches)
 group=0
 landscape_mode=TRUE
 longplot_reduction=1.0
 media_description{
  printable_bounds_llx=5.7937498093 (    P,PL%T 8_0)
  printable_bounds_lly=17.793750763 (    0#/+,4"%9@)
  printable_bounds_urx=273.60623169 (    (+,9<4"T7@)
  printable_bounds_ury=198.10624695 (    8&;#:$ <30)
  printable_area=48289.937117 ("J#
  dimensional=TRUE
  media_bounds{
   urx=279.39999390 (    8&9V<4!J5P)
   ury=215.89999390 (    P,S\:D"QW0)
  }
 }
}

 

A lot of that is straighforward, however I haven't figured out those encrypted looking sections trailing the bounds and area.  I'll look into adding the functionality this week and updating the Git project.  

 

Message 16 of 24
allockse
in reply to: SENL1362

Also, SENL1362 there's a Values collection (dictionary<string,string>) on each node to answer your question specifically. How does that help you? It currently doesn't because it's only internally exposed right now. You can change that in the PiaNode class though in the meantime if you wanted.
Message 17 of 24
SENL1362
in reply to: allockse

Thanks you for clarifying some details.

Reading the contents of the PC3(and indeed the PMP) is something i wished for a long time.

 

Nowadays w'll need the custom PaperFormats only when creating PDF's. For direct plotting we create custom PaperFormats in the PrinterDrivers and can then be accessed by the .NET plot software.

 

With youre software we could create the custom PaperFormats in the PC3 file and be completely independed from the supplied plotter configuration to generate all NamedPlotStyles, Layouts etc.

 

 

Message 18 of 24
SENL1362
in reply to: allockse

I was aware of that, while debugging i found a lot of usefull information.

In the sparse time left i am trying to understand the structure of these PiaNodes, but didn't want to change this framework as it is.

Looks promising.

 

Message 19 of 24
Ron_M
in reply to: SENL1362

What are you using for PDF plotting?  In Adobe I've created all of our custom sizes which are then accessible with the .pc3.

Message 20 of 24
SENL1362
in reply to: Ron_M

W'll use a modified PDF To DWG to create pdf files for each Layout.

 

Screenshot_1.png

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost