<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Aptos;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:12.0pt;
font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML - vooraf opgemaakt Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.HTML-voorafopgemaaktChar
{mso-style-name:"HTML - vooraf opgemaakt Char";
mso-style-priority:99;
mso-style-link:"HTML - vooraf opgemaakt";
font-family:"Consolas",serif;
mso-ligatures:none;
mso-fareast-language:#2000;}
span.E-mailStijl20
{mso-style-type:personal-reply;
font-family:"Aptos",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:11.0pt;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="en-NL" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Hello Jackie,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">I ran into a problem trying your code.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">This Line does not seem to work:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">vectorScaleRange.PointStyle.AddRule(pointRule)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Error when running the code:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><img width="794" height="107" style="width:8.2708in;height:1.1145in" id="Afbeelding_x0020_1" src="cid:image001.png@01DADDBD.2CF4D050"></span><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">I ran a dir() on the vectorScaleRange variable and it shows no AddRule.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">I will take a better look at the API documentation<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><img width="254" height="609" style="width:2.6458in;height:6.3437in" id="Afbeelding_x0020_2" src="cid:image002.png@01DADDBD.2CF4D050"></span><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="NL" style="font-size:11.0pt;mso-fareast-language:NL">Met vriendelijke groet,
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="NL" style="font-size:11.0pt;mso-fareast-language:NL"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="nl" style="color:black">GISkit BV<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="nl" style="color:black">Bart Oostdam</span><span lang="nl" style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="NL" style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="NL" style="font-size:11.0pt;font-family:"Calibri",sans-serif">Van:</span></b><span lang="NL" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> mapguide-users <mapguide-users-bounces@lists.osgeo.org>
<b>Namens </b>Jackie Ng via mapguide-users<br>
<b>Verzonden:</b> dinsdag 23 juli 2024 11:25<br>
<b>Aan:</b> MapGuide Users Mail List <mapguide-users@lists.osgeo.org><br>
<b>CC:</b> Jackie Ng <jumpinjackie@gmail.com><br>
<b>Onderwerp:</b> Re: [mapguide-users] IronPython - automate Maestro<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hi Bart,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Here's an example<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<blockquote style="margin-left:30.0pt;margin-right:0cm">
<div>
<p class="MsoNormal"><span style="font-family:"Courier New""># Get connection (assuming single active connection in Site Explorer)</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">conn = app.GetConnection(app.GetConnectionNames()[0])</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New""># Get Layer</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">layer = conn.ResourceService.GetResource("Library://Samples/Sheboygan/Layers/Trees.LayerDefinition")</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New""># Get the first scale range</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">vectorScaleRange = layer.SubLayer.GetScaleRangeAt(0)</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New""># The layer definition is also a factory for sub-elements you can add. In this case a new point rule</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">pointRule = layer.CreateDefaultPointRule()</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New""># Set various properties of this new rule</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">pointRule.LegendLabel = "New Point Rule"</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">#pointRule.Filter = "<my FDO filter expression>"</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New""># Add the new rule</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">vectorScaleRange.PointStyle.AddRule(pointRule)</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New""># Save the layer</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">conn.ResourceService.SaveResource(layer)</span><o:p></o:p></p>
</div>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Some general tips to help writing scripts:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">1. The IronPython console is a REPL, so don't be afraid of writing exploratory code fragments to inspect various variables and objects. You don't have to get the script code correct the first time round. Unfortunately, as I myself just
discovered, there's an annoying bug where you can't copy the current console contents to the clipboard (to paste into a reusable script) so building reusable scripts is a bit of a pain atm. This is a known issue that I'll look at a later time: <a href="https://github.com/jumpinjackie/mapguide-maestro/issues/152">https://github.com/jumpinjackie/mapguide-maestro/issues/152</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">2. This decade-old blog post of mine has some useful tips around the IronPython console: <a href="https://themapguyde.blogspot.com/2013/08/maestro-ironpython-console-tips-and.html">https://themapguyde.blogspot.com/2013/08/maestro-ironpython-console-tips-and.html</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">3. The objects you are interacting with are part of the Maestro .net API exposed to the IronPython engine, so it's useful to always have the .net API reference on hand when you want to know what a particular class or interface is: <a href="https://jumpinjackie.github.io/mapguide-maestro/api/">https://jumpinjackie.github.io/mapguide-maestro/api/</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Hope this helps!<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">- Jackie<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">You wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-left:30.0pt;margin-right:0cm">
<div>
<pre><span style="color:black">Hello,<o:p></o:p></span></pre>
</div>
<div>
<pre><span style="color:black">Maybe I am posting in the incorrect forum, still I hope someone can help me.<o:p></o:p></span></pre>
</div>
<div>
<pre><span style="color:black">I have been studying the (Iron)Python code examples that show how to alter existing items in Maestro.<o:p></o:p></span></pre>
</div>
<div>
<pre><span style="color:black">However, I would like to ‘add’ for instance new filters like point filters etc.<o:p></o:p></span></pre>
</div>
<div>
<pre><span style="color:black">After a few days trying I ran into something called ‘iPoint’.<o:p></o:p></span></pre>
</div>
<div>
<pre><span style="color:black">I have low-level programming skills.<o:p></o:p></span></pre>
</div>
<div>
<pre><span style="color:black">Could someone please provide an example of how to ADD a NEW filter ?<o:p></o:p></span></pre>
</div>
<div>
<pre><span style="color:black">Kine regards,<o:p></o:p></span></pre>
</div>
<div>
<pre><span style="color:black">Bart Oostdam<o:p></o:p></span></pre>
</div>
</blockquote>
</div>
</div>
</body>
</html>