<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
<title>CanonicalMediaName didn&#039;t change paper size</title>
<link>http://www.zwsoft.com/forum/viewthread.php?tid=1551</link>
<description>Hi  hkrnic,

thanks a lot for sharing !


   
</description>
<author>hkrnic</author>
<pubDate>2010-04-14 21:13:54</pubDate>
<item><link>http://www.zwsoft.com/forum/viewthread.php?tid=1551&amp;pid=12422</link>
<description>Wonderful ~~&lt;img src=&quot;http://classic.zwcad.org/forum/smileys/smiley32.gif&quot; height=&quot;17&quot; width=&quot;18&quot; border=&quot;0&quot; align=&quot;absmiddle&quot; alt=&quot;Clap&quot; /&gt; 
 
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</description>
<author>zw_admin</author>
<pubDate>2010-04-20 10:42:01</pubDate>
</item><item><link>http://www.zwsoft.com/forum/viewthread.php?tid=1551&amp;pid=12410</link>
<description> &lt;img src=&quot;smileys/smiley32.gif&quot; border=&quot;0&quot; align=&quot;middle&quot; /&gt; 
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 &quot;-2145320861&quot;
              MsgBox &quot;Nemogu snimiti crte? - &quot; &amp; Err.Description
        Case &quot;-2145386493&quot;
              MsgBox &quot;Crte? je postavljen na opcija Named Plot Styles.&quot; &amp; (Chr(13)) &amp; (Chr(13)) &amp; &quot;Startaj CONVERTPSTYLES naredbu&quot;, vbCritical, &quot;Change Plot Style&quot;
        Case Else
              MsgBox &quot;Nepoznata gre?ka &quot; &amp; 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 = &quot;Model&quot; 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?
            </description>
<author>hkrnic</author>
<pubDate>2010-04-15 16:31:19</pubDate>
</item><item><link>http://www.zwsoft.com/forum/viewthread.php?tid=1551&amp;pid=12403</link>
<description>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 &amp; &quot;_PlotConfig&quot;
    If ThisDocument.PlotConfigurations.Count &gt; 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 &quot;-2145320861&quot;
              MsgBox &quot;Nemogu snimiti crte? - &quot; &amp; Err.Description
        Case &quot;-2145386493&quot;
              MsgBox &quot;Crte? je postavljen na opcija Named Plot Styles.&quot; &amp; (Chr(13)) &amp; (Chr(13)) &amp; &quot;Startaj CONVERTPSTYLES naredbu&quot;, vbCritical, &quot;Change Plot Style&quot;
        Case Else
              MsgBox &quot;Nepoznata gre?ka &quot; &amp; 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?</description>
<author>hkrnic</author>
<pubDate>2010-04-14 20:51:37</pubDate>
</item>  </channel>
</rss>