<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Scripting: Select Model from OpenedModel Collection in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/scripting-select-model-from-openedmodel-collection/qaa-p/12087341#M4515829</link>
    <description>&lt;P&gt;My current solution is to directly address the models via their unique filepath:&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;'#Get PowerDesigner window as new object
Set PD = CreateObject("PowerDesigner.Application")
Output "  PowerDesigner window is loaded"
'#Select target and source model as objects&lt;BR /&gt;Dim filenameTargetModel, filenameOldSourceModel, filenameNewSourceModel&lt;BR /&gt;filenameTargetModel = "C:\GitRepos\xxx"
filenameNewSourceModel = "C:\GitRepos\yyy"
filenameOldSourceModel = "C:\GitRepos\zzz"
Set targetModel = PD.OpenModel(filenameTargetModel)
Set newSourceModel = PD.OpenModel(filenameNewSourceModel)
Set oldSourceModel = PD.OpenModel(filenameOldSourceModel)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 04 Dec 2019 11:40:27 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2019-12-04T11:40:27Z</dc:date>
    <item>
      <title>Scripting: Select Model from OpenedModel Collection</title>
      <link>https://community.sap.com/t5/technology-q-a/scripting-select-model-from-openedmodel-collection/qaq-p/12087338</link>
      <description>&lt;P&gt;Hello Community,&lt;/P&gt;
  &lt;P&gt;i am searching for the function or the method call to get a specific model from the List "Models" (which contains all opened models)&lt;/P&gt;
  &lt;P&gt;In PowerShell I can achieve this by&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;$powerDesigner = New-Object -com powerdesigner.application

$targetModel = $powerDesigner.Models | Where Code -eq $targetModelCode&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;In PowerShell I then have the model object in the variable targetModel.&lt;/P&gt;
  &lt;P&gt;I need the same now in VBScript. &lt;/P&gt;
  &lt;P&gt;Is there some kind of method like FindChildByCode for the Model List? The documentation says that Models is a global object reference list, but I don´t see a method to get a specific item out of this list...&lt;/P&gt;
  &lt;P&gt;Kind regards&lt;/P&gt;
  &lt;P&gt;Stephan&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 11:18:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/scripting-select-model-from-openedmodel-collection/qaq-p/12087338</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-10-16T11:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting: Select Model from OpenedModel Collection</title>
      <link>https://community.sap.com/t5/technology-q-a/scripting-select-model-from-openedmodel-collection/qaa-p/12087339#M4515827</link>
      <description>&lt;P&gt;I don't think you can do what you ask, as the collection is not a Named Object. You'll have to resort to this (someone with more programming experience may come up with a better approach):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;dim mdl
for each mdl in models
   if mdl.code = "PRODUCTS_AND_SERVICES_METAMODEL" then output mdl
next&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Oct 2019 15:02:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/scripting-select-model-from-openedmodel-collection/qaa-p/12087339#M4515827</guid>
      <dc:creator>GeorgeMcGeachie</dc:creator>
      <dc:date>2019-10-16T15:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting: Select Model from OpenedModel Collection</title>
      <link>https://community.sap.com/t5/technology-q-a/scripting-select-model-from-openedmodel-collection/qaa-p/12087340#M4515828</link>
      <description>&lt;P&gt;Perhaps something like this:&lt;/P&gt;&lt;P&gt;set ws = ActiveWorkspace &lt;/P&gt;&lt;P&gt;for each wsmdl in ws.children &lt;/P&gt;&lt;P&gt;   if wsmdl.modelType = "PDM" and not wsmdl.ModelObject is Nothing then&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 05:45:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/scripting-select-model-from-openedmodel-collection/qaa-p/12087340#M4515828</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-10-24T05:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting: Select Model from OpenedModel Collection</title>
      <link>https://community.sap.com/t5/technology-q-a/scripting-select-model-from-openedmodel-collection/qaa-p/12087341#M4515829</link>
      <description>&lt;P&gt;My current solution is to directly address the models via their unique filepath:&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;'#Get PowerDesigner window as new object
Set PD = CreateObject("PowerDesigner.Application")
Output "  PowerDesigner window is loaded"
'#Select target and source model as objects&lt;BR /&gt;Dim filenameTargetModel, filenameOldSourceModel, filenameNewSourceModel&lt;BR /&gt;filenameTargetModel = "C:\GitRepos\xxx"
filenameNewSourceModel = "C:\GitRepos\yyy"
filenameOldSourceModel = "C:\GitRepos\zzz"
Set targetModel = PD.OpenModel(filenameTargetModel)
Set newSourceModel = PD.OpenModel(filenameNewSourceModel)
Set oldSourceModel = PD.OpenModel(filenameOldSourceModel)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Dec 2019 11:40:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/scripting-select-model-from-openedmodel-collection/qaa-p/12087341#M4515829</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2019-12-04T11:40:27Z</dc:date>
    </item>
  </channel>
</rss>

