


{"id":349707,"date":"2024-02-07T15:45:08","date_gmt":"2024-02-07T15:45:08","guid":{"rendered":"\/forum\/forums\/reply\/349707\/"},"modified":"2024-02-07T16:00:59","modified_gmt":"2024-02-07T16:00:59","slug":"349707","status":"publish","type":"reply","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/349707\/","title":{"rendered":"Reply To: Mechanical Scripting: Pressure Import componentwise"},"content":{"rendered":"<p>&lt;p&gt;&nbsp;&lt;\/p&gt;&lt;p&gt;Hello,&lt;\/p&gt;&lt;p&gt;thank you for your support.&lt;\/p&gt;&lt;p&gt;The first part works, but I still cannot change the components of the pressure. When I try to add it to the code like that:&lt;\/p&gt;&lt;p&gt;&nbsp;&lt;\/p&gt;<\/p>\n<pre>&lt;span style=\"font-size: 12pt;\"&gt;<em>mechScriptCmds=\"\"\"\nwbAnalysisName = '{3}'\nfor item in ExtAPI.DataModel.AnalysisList:\n&nbsp; &nbsp; if item.SystemCaption == wbAnalysisName:\n&nbsp; &nbsp; &nbsp; &nbsp; analysis = item\nmycaption = analysis.SystemCaption\nExtAPI.Log.WriteMessage(mycaption)\nwith Transaction():\n&nbsp; &nbsp; import glob\n&nbsp; &nbsp; import os\n&nbsp; &nbsp; DataPath = r'{0}'\n&nbsp; &nbsp; DataExtension = '{1}'\n&nbsp; &nbsp; allfiles = glob.glob1(DataPath,\"*.\" + DataExtension)\n&nbsp; &nbsp; allfiles.sort(key=lambda f: int(''.join(filter(str.isdigit, f))))\n&nbsp; &nbsp; numfilestoload = len(allfiles)\n&nbsp; &nbsp; importedloadobjects = [child for child in analysis.Children if child.DataModelObjectCategory.ToString() == \"ImportedLoadGroup\"]\n&nbsp; &nbsp; usedimportedloadobj = importedloadobjects[-1]\n&nbsp; &nbsp; importedPres = usedimportedloadobj.AddImportedPressure()&lt;br&gt;&lt;span style=\"background-color: rgb(251, 238, 184);\"&gt;    DefineByProp = importedPres.PropertyByName('PROPID_DefineByType')&lt;\/span&gt;&lt;br&gt;&lt;span style=\"background-color: rgb(251, 238, 184);\"&gt;    DefineByProp = 0 &nbsp; &nbsp;# 0=\"Components\", 2=\"Normal To\"&lt;\/span&gt;&lt;br&gt;  &nbsp; namedsel_importedload = ExtAPI.DataModel.GetObjectsByName('{2}')[0]\n&nbsp; &nbsp; importedPres.Location = namedsel_importedload\n&nbsp; &nbsp; table = importedPres.GetTableByName(\"\")\n&nbsp; &nbsp; for i in range(numfilestoload-1):\n&nbsp; &nbsp; &nbsp; &nbsp; table.Add(None)\n&nbsp; &nbsp; for i in range(numfilestoload):\n&nbsp; &nbsp; &nbsp; &nbsp; table[i][0] = \"File\"+str(i+1)+\":\"+str(allfiles[i])&lt;br&gt;&lt;span style=\"background-color: rgb(251, 238, 184);\"&gt;&nbsp; &nbsp; &nbsp; &nbsp; table[i][1] = \"File\"+str(i+2)+\":\"+str(allfiles[i+1])&lt;\/span&gt;&lt;br&gt;&lt;span style=\"background-color: rgb(251, 238, 184);\"&gt;&nbsp; &nbsp; &nbsp; &nbsp; table[i][2] = \"File\"+str(i+3)+\":\"+str(allfiles[i+2])&lt;\/span&gt;&lt;br&gt;  &nbsp; &nbsp; &nbsp; table[i][3] = (i+1)*100&lt;br&gt;  &nbsp; importedPres.ImportLoad()\n\"\"\".format(DataPath,DataExtension,namedSelectionUsed,systemName)\nmodel2 = system2.GetContainer(ComponentName=\"Model\")&nbsp;\nmodel2.SendCommand(Language=\"Python\", Command=mechScriptCmds) &lt;br&gt;<\/em>&lt;\/span&gt;<\/pre>\n<p>&lt;p&gt;&nbsp;&lt;\/p&gt;&lt;p&gt;When I run it nothing happens. I have of course tried several writing variations, but it doesn&rsquo;t work. The components are apparently not turned on and therefore no further columns are created.&lt;\/p&gt;&lt;p&gt;I also tried it like that, but it also doesnt work&hellip; I have seen this spelling several times, but never for imported pressure&lt;\/p&gt;&lt;p&gt;&nbsp;&lt;\/p&gt;<\/p>\n<pre>&lt;span style=\"background-color: rgb(251, 238, 184);\"&gt;&lt;span style=\"font-size: 12pt; background-color: rgb(251, 238, 184);\"&gt;<em>&lt;span class=\"n\"&gt;ImportedPres&lt;\/span&gt;<\/em>&lt;\/span&gt;&lt;span style=\"font-size: 12pt; background-color: rgb(251, 238, 184);\"&gt;<em>&lt;span class=\"o\"&gt;.&lt;\/span&gt;&lt;span class=\"n\"&gt;DefineBy&lt;\/span&gt; &lt;span class=\"o\"&gt;=&lt;\/span&gt; &lt;span class=\"n\"&gt;LoadDefineBy&lt;\/span&gt;&lt;span class=\"o\"&gt;.&lt;\/span&gt;&lt;span class=\"n\"&gt;Components&lt;\/span&gt;<\/em>&lt;\/span&gt;&lt;\/span&gt;<\/pre>\n<p>&lt;p&gt;&nbsp;&lt;\/p&gt;&lt;p&gt;Best regards&lt;\/p&gt;&lt;p&gt;Dayana&lt;\/p&gt;&lt;p&gt;&nbsp;&lt;\/p&gt;<\/p>\n<pre>&nbsp;<\/pre>\n","protected":false},"template":"","class_list":["post-349707","reply","type-reply","status-publish","hentry"],"aioseo_notices":[],"acf":[],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies\/349707","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/types\/reply"}],"version-history":[{"count":1,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies\/349707\/revisions"}],"predecessor-version":[{"id":349708,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies\/349707\/revisions\/349708"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=349707"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}