<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Deleting a function block</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1429d1b8d0/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1429d1b8d0/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/1429d1b8d0/</id><updated>2020-02-27T14:56:12.993000Z</updated><subtitle>Recent posts to Deleting a function block</subtitle><entry><title>Deleting a function block</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1429d1b8d0/?limit=25#ef7b" rel="alternate"/><published>2020-02-27T14:56:12.993000Z</published><updated>2020-02-27T14:56:12.993000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com0e7e838e90127b1610bfe6cf9c3a4f3ef169aa5a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; M.Schaber&lt;/p&gt;
&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The problem is that the path to the executable contains spaces. Simply adding double quotes around the command path seems not to work. This seems to be a problem in the windows implemenation of os.system or the underlying windows function.&lt;/p&gt;
&lt;p&gt;The solution is to add an additional pair of double quotes around the whole command string. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;system&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s1"&gt;'""C:\Program Files (x86)\3S CoDeSys\CoDeSys\Common\CoDeSys.exe" --Profile="CoDeSys V3.4 SP4 Patch 1""'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;This looks weird, but it worked in my tests on Windows 7.&lt;/p&gt;
&lt;p&gt;Btw, I found the solutions at: &lt;a class="" href="http://stackoverflow.com/questions/204017/how-do-i-execute-a-program-from-python-os-system-fails-due-to-spaces-in-path" rel="nofollow"&gt;http://stackoverflow.com/questions/2040 ... es-in-path&lt;/a&gt; m &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Deleting a function block</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1429d1b8d0/?limit=25#73e7" rel="alternate"/><published>2020-02-27T14:56:11.273000Z</published><updated>2020-02-27T14:56:11.273000Z</updated><author><name>aoj</name><uri>https://forge.codesys.com/u/aoj/</uri></author><id>https://forge.codesys.comff24cc780be7d0c24edbe9cc6be2078670961756</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hallo,&lt;/p&gt;
&lt;p&gt;I have a problem with starting CoDeSys from Python.&lt;/p&gt;
&lt;p&gt;I was trying to start CoDeSys with the following command: &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;system&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s1"&gt;'C:\3S CoDeSys\CoDeSys\Common\CoDeSys.exe --Profile="CoDeSys V3.4 SP4 Patch 1"'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="o"&gt;```&lt;/span&gt; &lt;span class="n"&gt;but&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="n"&gt;did&lt;/span&gt; &lt;span class="k"&gt;not&lt;/span&gt; &lt;span class="k"&gt;work&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="n"&gt;So&lt;/span&gt; &lt;span class="n"&gt;I&lt;/span&gt; &lt;span class="k"&gt;found&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;solution&lt;/span&gt; &lt;span class="k"&gt;and&lt;/span&gt; &lt;span class="n"&gt;I&lt;/span&gt; &lt;span class="n"&gt;started&lt;/span&gt; &lt;span class="k"&gt;to&lt;/span&gt; &lt;span class="n"&gt;use&lt;/span&gt; &lt;span class="n"&gt;this&lt;/span&gt; &lt;span class="n"&gt;command&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;os.system(r'C:\3S" CoDeSys\CoDeSys\Common\CoDeSys.exe --Profile="CoDeSys V3.4 SP4 Patch 1"')&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;After&lt;/span&gt; &lt;span class="n"&gt;downloading&lt;/span&gt; &lt;span class="n"&gt;CoDeSys&lt;/span&gt; &lt;span class="k"&gt;on&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;PC&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;I&lt;/span&gt; &lt;span class="n"&gt;changed&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="n"&gt;CoDeSys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="n"&gt;So&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;Command&lt;/span&gt; &lt;span class="n"&gt;looks&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="k"&gt;like&lt;/span&gt; &lt;span class="n"&gt;that&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;os.system(r'C:\Program Files (x86)\3S CoDeSys\CoDeSys\Common\CoDeSys.exe --Profile="CoDeSys V3.4 SP4 Patch 1"')&lt;/p&gt;
&lt;p&gt;```&lt;/p&gt;
&lt;p&gt;I have the same problem again. CoDeSys does not start! What could be the solution?&lt;/p&gt;
&lt;p&gt;Thank you and wishe u a nice weekend.  &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Deleting a function block</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1429d1b8d0/?limit=25#58de" rel="alternate"/><published>2020-02-27T14:56:10.665000Z</published><updated>2020-02-27T14:56:10.665000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com5016c109e9edb4c4db2aabb4468aab7329001314</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; M.Schaber&lt;/p&gt;
&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The second parameter indicates whether the search is recursive or not. Thus, project.find("foo", False) only finds top-level objects, whereas find("foo", True) searches deeper in the hierarchy.&lt;/p&gt;
&lt;p&gt;There's a second variant of the find() method which takes the path as list of strings. So you can find a specific application via a command like: ```&lt;/p&gt;
&lt;p&gt;proj.find('Foobar_Device', 'Plc Logic', 'Application')&lt;span&gt;[0]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;```&lt;/p&gt;
&lt;p&gt;Note that also objects have a find() method, so you can search inside a folder or an application by calling the find method on that object.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Deleting a function block</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1429d1b8d0/?limit=25#53f4" rel="alternate"/><published>2020-02-27T14:56:10.038000Z</published><updated>2020-02-27T14:56:10.038000Z</updated><author><name>aoj</name><uri>https://forge.codesys.com/u/aoj/</uri></author><id>https://forge.codesys.comc582d7729bdc164367939a130d57928548cf102c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi, &lt;/p&gt;
&lt;p&gt;now it works. My mistake was, that I hade &lt;strong&gt;('DeviceName', False)&lt;/strong&gt;.&lt;br/&gt;
What do those &lt;strong&gt;False&lt;/strong&gt; and &lt;strong&gt;True&lt;/strong&gt; exactly mean or how do they influence the script?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Deleting a function block</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1429d1b8d0/?limit=25#10e9" rel="alternate"/><published>2020-02-27T14:56:08.396000Z</published><updated>2020-02-27T14:56:08.396000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comcfb7900f3001484e7ab30053f715d1dff7475a4c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; M.Schaber&lt;/p&gt;
&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;What exactly means "not working"? Do you get an error message? Or is the POU simply not deleted?&lt;/p&gt;
&lt;p&gt;I just tried a minimal version which works for me: It removes the first object with the name PLC_PRG.&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;projects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;primary&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;"PLC_PRG"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Please keep in mind that the text decorations displayed in the trees are not part of the name. So if the object is displayed as "POU (FB)" in the tree, the real name of the object is "POU". You have several ways to display the real name: If you click on the name of the object to rename it, you see "POU", the real name. Or if you open the "POU" in an editor, the editor tab displays the real name "POU". Or if you view the object properties (via context menu), or dump the object tree with an python script.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Deleting a function block</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1429d1b8d0/?limit=25#3df8" rel="alternate"/><published>2020-02-27T14:56:07.826000Z</published><updated>2020-02-27T14:56:07.826000Z</updated><author><name>aoj</name><uri>https://forge.codesys.com/u/aoj/</uri></author><id>https://forge.codesys.com1f2a709efdf223fb7c0b5c79bb4274d3dd65a542</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;thank you for the answer. I have tried this but it is not working. What I exactly want to do is deletding the POU(FB).&lt;/p&gt;
&lt;p&gt;Does that work with the same command?&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Unbenannt.JPG" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=269"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Deleting a function block</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1429d1b8d0/?limit=25#ee18" rel="alternate"/><published>2020-02-27T14:56:07.251000Z</published><updated>2020-02-27T14:56:07.251000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com0647abe9060f1e76c377d50f17397cc62e0df72f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; M.Schaber&lt;/p&gt;
&lt;p&gt;Hi, it is.&lt;/p&gt;
&lt;p&gt;You search the function block by its name, via the find() method of the project.&lt;/p&gt;
&lt;p&gt;Then you call the remove() method on the object.&lt;/p&gt;
&lt;p&gt;HTH,&lt;br/&gt;
Markus.&lt;/p&gt;
&lt;p&gt;PS: Remind that find() returns a list of objects, not a single object, as there may be several objects with the same name in the tree.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Deleting a function block</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/1429d1b8d0/?limit=25#4e81" rel="alternate"/><published>2020-02-27T14:56:05.636000Z</published><updated>2020-02-27T14:56:05.636000Z</updated><author><name>aoj</name><uri>https://forge.codesys.com/u/aoj/</uri></author><id>https://forge.codesys.com6a111d7f1d1e5f7b8d8d6bee005f962829af542a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi hi,&lt;/p&gt;
&lt;p&gt;if I have a CoDeSys-Project with many function blocks, is it possible to delete 1 function block with a python-command?&lt;/p&gt;
&lt;p&gt;Thank you  &lt;/p&gt;&lt;/div&gt;</summary></entry></feed>