CAD/CAM discussion forum > Other CAD/CAM Technology > CanonicalMediaName didn't change paper size

CanonicalMediaName didn't change paper size

Rank: 1

Hrvoje Krnić

Newbie

posts: 0

Registered: 2010-7-15

Message 1 of 4

14-04-2010 08:51 . pm | View his/her posts only
In my previous topic I try get all CanonicalMediaNames, and find solution. Now, in my application, when user select plot device and media names I want setup plot for new created layout. This is my procedure for setting layout plot device:

Private Sub SetupAndPlot(ByRef layout As ZwcadLayout, newPrinterName As String, newStyleSheet As String, newCanonicalMediaName As String, newStandardScale As String, newPlotRotation As String)
On Error GoTo Err_Control
Dim plotconfig As ZwcadPlotConfiguration
Dim configName As String
Dim bFound As Boolean

configName = layout.Name & "_PlotConfig"
If ThisDocument.PlotConfigurations.Count > 0 Then
bFound = False
For Each plotconfig In ThisDocument.PlotConfigurations
If plotconfig.Name = configName Then
bFound = True
Exit For
End If
Next

If Not bFound Then
Set plotconfig = ThisDocument.PlotConfigurations.Add(configName)
End If
Else
Set plotconfig = ThisDocument.PlotConfigurations.Add(configName)
End If

plotconfig.configName = newPrinterName
plotconfig.PlotType = zcLayout
plotconfig.StyleSheet = newStyleSheet
plotconfig.CanonicalMediaName = newCanonicalMediaName
plotconfig.StandardScale = newStandardScale
plotconfig.PlotRotation = newPlotRotation
plotconfig.PaperUnits = zcMillimeters
plotconfig.PlotWithPlotStyles = True
plotconfig.PlotViewportBorders = False
plotconfig.PlotViewportsFirst = True
plotconfig.ShowPlotStyles = False
plotconfig.CenterPlot = True

layout.CopyFrom plotconfig

ThisDocument.Regen

Exit_Here:
Exit Sub
Err_Control:
Select Case Err.Number
Case "-2145320861"
MsgBox "Nemogu snimiti crte? - " & Err.Description
Case "-2145386493"
MsgBox "Crte? je postavljen na opcija Named Plot Styles." & (Chr(13)) & (Chr(13)) & "Startaj CONVERTPSTYLES naredbu", vbCritical, "Change Plot Style"
Case Else
MsgBox "Nepoznata gre?ka " & Err.Number
End Select
End Sub

When user select media like ISO_A2_(594.00_x_420.00_MM), and execute procedure SetupAndPlot, layout.GetPaperSize
give (279,4 x 215,9) dimenzion. I expected 594 x 420 mm. Layout.CanonicalMediaName return ISO_A2_(594.00_x_420.00_MM).
In layout, edge off paper are set on (279,4 x 215,9).
If I start Page Setup of layout, paper is set to ISO_A2_(594.00_x_420.00_MM). Then I reselect ISO_A2_(594.00_x_420.00_MM) and dimenzion on layout is changed to 594x420mm.
Where I failed in confirming selected media?

Rank: 1

Lars

Newbie

posts: 0

Registered: 2010-12-14

Message 2 of 4

 CanonicalMediaName didn't change paper size
14-04-2010 09:13 . pm | View his/her posts only
Hi hkrnic,

thanks a lot for sharing !



Rank: 1

Hrvoje Krnić

Newbie

posts: 0

Registered: 2010-7-15

Message 3 of 4

15-04-2010 04:31 . pm | View his/her posts only

Hmmm, hmmm, hmmm.
Here short plot setup solution:

Private Sub SetupAndPlot(ByRef layout As ZwcadLayout, newPrinterName As String, newStyleSheet As String, newCanonicalMediaName As String, newStandardScale As String, newPlotRotation As String)
On Error GoTo Err_Control
Dim configName As String
Dim bFound As Boolean

layout.configName = newPrinterName
layout.PlotType = zcLayout
layout.StyleSheet = newStyleSheet
layout.CanonicalMediaName = layout.GetLocaleMediaName(newCanonicalMediaName)
layout.StandardScale = newStandardScale
layout.PlotRotation = newPlotRotation
layout.PaperUnits = zcMillimeters
layout.PlotWithPlotStyles = True
layout.PlotViewportBorders = False
layout.PlotViewportsFirst = True
layout.ShowPlotStyles = False
layout.CenterPlot = True

ThisDocument.Regen

Exit_Here:
Exit Sub
Err_Control:
Select Case Err.Number
Case "-2145320861"
MsgBox "Nemogu snimiti crte? - " & Err.Description
Case "-2145386493"
MsgBox "Crte? je postavljen na opcija Named Plot Styles." & (Chr(13)) & (Chr(13)) & "Startaj CONVERTPSTYLES naredbu", vbCritical, "Change Plot Style"
Case Else
MsgBox "Nepoznata gre?ka " & Err.Number
End Select
End Sub

I choose wrong paper size ISO_expand_A2_(594.00_x_420.00_MM) instead ISO_A2_(594.00_x_420.00_MM).
We here have another problem. Layout doesn't want show new edge of paper. I solved this problem activated MODEL layout and than again new layout.
Here is code for that:

Dim NewLayout As ZwcadLayout
Dim objLayout As ZwcadLayout

NewLayout = ThisDocument.activeLayout
For Each objLayout In ThisDocument.Layouts
If objLayout.Name = "Model" Then
ThisDocument.activeLayout = objLayout
Exit For
End If
Next

ThisDocument.activeLayout = NewLayout

Now new layout show true edge of paper.
Can somebody know simple method?

Rank: 1

OldForumPost

Newbie

posts: 0

Registered: 2012-1-14

Message 4 of 4

20-04-2010 10:42 . am | View his/her posts only
Wonderful ~~Clap

Thank you for your share very much, Hkrnic~ It is really intresting and helpful. I am leaning it now. There maybe some more effective way, but I could think out for the time being. Anybody else?Denny2010-04-20 10:43:48
See also