Atom topic feed | site map | contact | login | Protection des données personnelles | Powered by FluxBB | réalisation artaban
You are not logged in.
Pages: 1
Hello All,
As the year and decade come to a close I wish you all the:
Best of the Holiday Season and a Wonderful New Year!
This week's puzzle is a challenge for the holidays and involves writing a Salome plugin to create / draw an offset wire given:
1) any pre-defined "Wire_1";
2) a value for the offset and
3) a boolean variable specifying on which side the new wire must lie.
Since you will have some time to spend between eating cookies / cake or popping champagne, ponder some bit about how it can be done!
The Salome website has clues about where to place the python code so that it will pop-up in the menu structure of Salome514/515. Remember that plug-ins only work in Version 5.1.4 and 5.1.5, but your python code can always be used as a standalone script too. So do not be discouraged if you think this is an ambitious task. Take a shot at it...
Good Luck!
JMB
PS: Previous puzzles are waiting for submissions or fresh ideas!
Last edited by JMB365 (2010-12-18 17:42:16)
SalomeMeca 2021
Ubuntu 20.04, 22.04
Offline
Happy Christmas for you all as well.
rui
Offline
1) any pre-defined "Wire_1";
2) a value for the offset and
3) a boolean variable specifying on which side the new wire must lie.
A newbie question ... what do you mean exactly ?
Offline
Hello eam,
To clarify, here is a simple python code for two square wires. It generates Wire_1 first. Then Wire_2 which is offset (by 2) to one side (the inside):
import GEOM, geompy, math, SALOMEDS
Wire_1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 10 0:TT 10 10:TT 0 10:WW", [0, 0, 0, 0, 0, 1, 1, 0, -0])
Wire_2 = geompy.MakeSketcher("Sketcher:F 1.414 1.414:TT 8.586 1.414:TT 8.586 8.586:TT 1.414 8.586:WW", [0, 0, 0, 0, 0, 1, 1, 0, -0])
geompy.addToStudy( Wire_1, "Wire_1" )
geompy.addToStudy( Wire_2, "Wire_2" )
The second possibility is to have a 'Wire_3' which is offset by 2 on the outside. The purpose of the boolean is to specify which one of the two possibilities the user wants.
So the function call can be something like createOffsetWire('Wire_1', 'Wire_2', 2.0, 0), meaning use 'Wire_1 as the basis, create a new wire called 'Wire_2', offset by 2.0 units and on the Inside (0). The outside could be specified as '1'.
The puzzle challenge is to write a generic python code ('createOffsetWire') that works for any 'Wire_1'. Hope this helps explain the objective. Good Luck!
Regards, JMB
SalomeMeca 2021
Ubuntu 20.04, 22.04
Offline
Happy New Year All !!!
In an effort to jump start this puzzle I am posting a snippet of code that can help getting to the finish line. But the meat of the program will have to come from Puzzle Solvers!
The code posted below shows how a Salome plug-in can be be easily incorporated. It allows one to open a text editor (gedit) to open a named study that has a file name with the extension ".inp" so one can edit it prior to starting a solver run.
import salome_pluginsmanager
# Call Editor:
def Abaqus_Gedit_Inp(Dummy_Var):
import subprocess
import os
msg1 = "The PathName to the study is not specified!\n \
Set it using something like:\n \
PathName = '/home/.../Somewhere/'\n \
os.environ['PathName'] = PathName\n \
(In the Salome Python Console)\n"
msg2 = "The BaseName of the study is not specified!\n \
Set it using something like:\n \
BaseName = 'Test4'\n \
os.environ['BaseName'] = BaseName\n \
(In the Salome Python Console)\n"
Path2Use = os.getenv('PathName')
File2Use = os.getenv('BaseName')
Edit2Use = os.getenv('Editor')
Ext2Use = os.getenv('Abaqus_Ext')
if Edit2Use is None :
Edit2Use = 'gedit '
if Ext2Use is None :
Ext2Use = '.inp'
if Path2Use is None or Path2Use == "" :
raise Exception(msg1)
if File2Use is None or File2Use == "" :
raise Exception(msg2)
msg3 = "The PathName to the study", Path2Use, "does not exist!"
if not os.path.isfile(Path2Use) :
raise Exception(msg3)
Command = Edit2Use + " " + Path2Use + File2Use + Ext2Use
External_Call = subprocess.Popen(Command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT);
Make suitable changes to the code for your setup and save it in any location you choose in a file named as salome-plugins.py and then configure Salome 5.1.4 or 5.1.5 to recognize and load it by modifying the env_products.sh as follows:
sudo cp /opt/salome_5.1.5/env_products.sh /opt/salome_5.1.5/env_products.sh.orig
sudo gedit /opt/salome_5.1.5/env_products.sh &
and add:
##
#------ SALOME-plugins ------
export SALOME_PLUGINS_PATH=/...path_where_you_saved_it.../Salome-plugins
Launch salome, open a study, and "Tools/Plugins" should have an "Abaqus Inp Editor" visible! Enjoy and Good Luck writing the main code for last year's unsolved puzzle...
Regards, JMB
Last edited by JMB365 (2011-01-07 02:20:40)
SalomeMeca 2021
Ubuntu 20.04, 22.04
Offline
Hi JMB,
this is really close to programming...
i think the salomes geometry gui is kind of tough to use, compared to solidwork i use daily.
althou this is a great feature to have in salome, i'll save my efforts for meshing and Analising puzzles.
greetings to all, and happy 2011.
rui
Offline
Hello All,
Christian Caremoli recently posted a patch to the Salome plugins feature that now allows one to categorize plugins by sub-menus and the order in which one would like to see them show up in the menus. I downloaded the patch and it works very well. I strongly encourage you to try it out, since it will allow you to add to the functionality of Salome as you learn to write Python scripts. I was impressed by how quickly my request for an enhancement was acted upon. Thank you Christian!
See: http://www.salome-platform.org/forum/forum_12/762824139
This should encourage all of us to delve into improving Salome, by writing small pieces of code that can become the building blocks of neat capabilities of the software. I am still hoping that somebody is working on the puzzles!
Regards, JMB
SalomeMeca 2021
Ubuntu 20.04, 22.04
Offline
Pages: 1