.NET

Reply
Valued Contributor
fallright
Posts: 75
Registered: ‎09-14-2009
Message 1 of 12 (880 Views)

papersize

880 Views, 11 Replies
08-13-2010 12:45 PM

Can anyone help me to  add an also to edit a custom papersize to the "DWG to PDF.pc3"  file.  Or give me a least a hint? Thanks in advance. I'm already this far:

 <CommandMethod("cpss")> _
Public Sub cpss()
        Dim plottername, papersiize As String
        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim acCurDb As Database = acDoc.Database
        plottername = "DWG to PDF.pc3"
        papersiize = "ISO_expand_A3_(420.00_x_297.00_MM)"
        Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
            Dim acLayoutMgr As LayoutManager
            acLayoutMgr = LayoutManager.Current
            Dim acLayout As Layout
            acLayout = acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout), OpenMode.ForRead)
            acDoc.Editor.WriteMessage(vbLf & "Current layout: " & acLayout.LayoutName)
            acDoc.Editor.WriteMessage(vbLf & "Current device name: " & acLayout.PlotConfigurationName)
            Dim acPlInfo As PlotInfo = New PlotInfo()
            acPlInfo.Layout = acLayout.ObjectId
            Dim acPlSet As PlotSettings = New PlotSettings(acLayout.ModelType)
            acPlSet.CopyFrom(acLayout)
            Dim acPlSetVdr As PlotSettingsValidator = PlotSettingsValidator.Current
            acPlSetVdr.SetPlotConfigurationName(acPlSet, plottername, papersiize)
            Dim rutte As New Extents2d(0, 0, 420, 297)
            acPlSetVdr.SetPlotWindowArea(acPlSet, rutte)
            acPlSetVdr.SetPlotType(acPlSet, Autodesk.AutoCAD.DatabaseServices.PlotType.Window)
            acPlSetVdr.SetUseStandardScale(acPlSet, True)
            acPlSetVdr.SetPlotOrigin(acPlSet, New Point2d(0, 0))
            acPlSetVdr.SetPlotRotation(acPlSet, PlotRotation.Degrees000)
            acPlSetVdr.SetStdScaleType(acPlSet, StdScaleType.StdScale1To1)
            acPlSetVdr.SetPlotCentered(acPlSet, True)
            acLayout.UpgradeOpen()
            acLayout.CopyFrom(acPlSet)
            acDoc.Editor.WriteMessage(vbLf & "New device name: " & acLayout.PlotConfigurationName)
            acTrans.Commit()
        End Using
    End Sub

 

Valued Mentor
fieldguy
Posts: 382
Registered: ‎03-31-2005
Message 2 of 12 (874 Views)

Re: papersize

08-13-2010 01:10 PM in reply to: fallright

For some reason, setplotconfigurationname is expecting canonical media name as the last parameter.  Kean has an example here: http://through-the-interface.typepad.com/through_the_interface/2007/10/allowing-select.html.

 

When I had to add a custom page size, I just used autocad and edited the PC3 file.  I have not used .net to do that. 

Valued Mentor
fieldguy
Posts: 382
Registered: ‎03-31-2005
Message 3 of 12 (871 Views)

Re: papersize

08-13-2010 01:14 PM in reply to: fallright

Sorry.  I see you have that already - papersiize.  What is the error?

Valued Contributor
fallright
Posts: 75
Registered: ‎09-14-2009
Message 4 of 12 (866 Views)

Re: papersize

08-13-2010 01:32 PM in reply to: fieldguy

papersiize is not an error; it is only a the name of a variable (not so good chosen, I agree).

 

As fas I can see the trhough-the-interface manual doesn't make new custom paper size, it only select existing paper sizes.

 

I explain why I want to program this:

I have a layout and I want to make a PDF of it.

The paper size of the plan is always changing with different projects, This is why I have to make for every different plot I make I have to define a new custom paper size. I find this very time consuming and I'm always aware that this paper space is defined by plot-scale in combination with the selected window that you want to plot.

For some reason the option "change paper size to the selected window in combination with selected paperscale" " is not within Autocad.

That is why I want to make a program and that is why I want to change/create a custom paper size and why I don't manualy make every possible paper size I could need in the future.

 

Valued Mentor
Jeffrey_H
Posts: 372
Registered: ‎01-20-2010
Message 5 of 12 (864 Views)

Re: papersize

08-13-2010 02:02 PM in reply to: fallright

Would you load a dwg with multiple layouts or something to show why you have to create a custom papersize for each plot

You can also find your answers @ TheSwamp
Valued Contributor
fallright
Posts: 75
Registered: ‎09-14-2009
Message 6 of 12 (854 Views)

Re: papersize

08-13-2010 02:59 PM in reply to: fallright

Here is the example (see zip in attach)

I want to make a PDF of Layout.

 

This is what I have to do in Autocad

   - plotscale is 20mm = 1 unit
   - window of the plan is 45 by 45 units
   - so the paper size is 900 by 900 mm
   - go to "dwg to PC3", make a new custom paper size 900 by 900 (this step is too time consuming for me)

   - set this current

   - plot

Another plan/layout with different size and these steps must be done again

 

This is what the program have to do:

   - start program

   - the program determines the plotscale (with this I have no programming-problem)

   - the program detemines the plotwindow (with this I have no programming-problem)

  - the program calculates the paper size en makes it current

  - the program start to make the PDF (with this I have no programming-problem)

  - result : 1 click

 

 

 

Valued Mentor
Jeffrey_H
Posts: 372
Registered: ‎01-20-2010
Message 7 of 12 (848 Views)

Re: papersize

08-13-2010 04:28 PM in reply to: fallright

Sorry not trying to irrate you but why do you not use standard paper sizes does this not cause probles when the plans go out for print or is this like preliminary half size I noticed it is metric we do work all over the world, The reasons I am asking you these questions I ran across a similar thing do not know how similair yet but went at it a different way

You can also find your answers @ TheSwamp
Valued Contributor
fallright
Posts: 75
Registered: ‎09-14-2009
Message 8 of 12 (839 Views)

Re: papersize

08-14-2010 01:11 AM in reply to: fallright

You're not anoying at all. Discussion leads to a solution.

 

In our office we have a plotter with a paper roll of 100m. So the width of the plan is fixed, the length isn't. We mostly make road design plan. The length of the plan is mostly the length of the road to design scaled 500 times. It is true that I could make 15 extra paper size (fix width and 15 different lenghts), but I'm sure that the program that I want to make leads to more usercomfort (perhaps a little more, but I really want to program it).

 

 

Valued Mentor
Jeffrey_H
Posts: 372
Registered: ‎01-20-2010
Message 9 of 12 (836 Views)

Re: papersize

08-14-2010 04:05 AM in reply to: fallright

AcPlPlotInfoValidator::isCustomPossible (you can place this in the index search of the arxdoc.chm for more info)

 

Checks to see if the validator can create a custom media size using the specified AcPlPlotInfo object. No validation of the object is performed by this method, and the object does not need to be validated before calling this method. The layout, plot settings overrides, and device override are obtained from the AcPlPlotInfo object to determine what page size and device would be used to create the custom media size. 

The method returns a value containing coded bitwise OR flags of the eCustomSizeResult enum, indicating what (if any) problems would be encountered creating a custom paper size for the device. 

 

 

 

You can go to theswamp.org and on the second page look for the post  DumpBin Results for PINVOKE to see if you pinvoke something like this.

 

Or tell your boss you have start following NCS and used defined paper sizes

You can also find your answers @ TheSwamp
Valued Mentor
Jeffrey_H
Posts: 372
Registered: ‎01-20-2010
Message 10 of 12 (835 Views)

Re: papersize

08-14-2010 04:11 AM in reply to: Jeffrey_H

Sorry that was just for validation

You can also find your answers @ TheSwamp
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.