/cwd will not change the directory if there are blank spaces in name
See original GitHub issueI am trying to set the directory where a pymapdl analysis results will be saved using the /cwd command. I have found that if the directory name has spaces, the /cwd will not write the apdl output to that folder.
Example: Directory ‘BOB’ will have the expected results but directory ‘BOB with Spaces’ is empty when I run the .py script below. Run from a directory without spaces, naturally.
from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl(verbose_mapdl=True, additional_switches='-smp', override=True , log_apdl='apdl.log', loglevel='ERROR')
import os
dirNames = ['BOB', 'BOB with Spaces'] # run from a directory w/out spaces!
local = os.getcwd()
for d in dirNames:
setLocal = os.path.join(local,d)
if not os.path.isdir(setLocal):
os.mkdir(setLocal)
print(setLocal)
#setLocal = "/CWD," + local
mapdl.cwd(setLocal )
x = 1
fx =- 1e6
numElem = 1000
elemSize = (x*x*x)/numElem**(1/3)
####
mapdl.clear()
mapdl.prep7()
mapdl.mp("EX", 1, 200e9)
mapdl.mp("PRXY", 1, 0.3)
mapdl.csys(0)
mapdl.blc4(0, 0,x,x, x)
mapdl.et(1, "SOLID186")
mapdl.type(1)
mapdl.keyopt(1, 2, 1)
mapdl.esize(elemSize)
mapdl.vmesh("ALL")
#mapdl.eplot()
# fixed constraint
mapdl.nsel("s", "loc", "x", 0)
mapdl.d("all", "all")
# arbitrary non-uniform load
mapdl.nsel("s", "loc", "x", x)
mapdl.f("all", "fx",fx)
mapdl.allsel()
mapdl.run("/solu")
sol_output = mapdl.solve()
#mapdl.post_processing.plot_nodal_displacement(lighting=False, show_edges=True)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
shell - POSIX/C: chdir() not changing the directory with spaces?
If you issue a shell command like cd , the shell interprets the command line and splits it at unescaped whitespace.
Read more >Navigating Directories:The CWD, PWD, and CDUP commands
A CWD request has a nonempty parameter giving an encoded pathname. It asks the server to set the name prefix to this pathname,...
Read more >bash - cannot change to directory with space character in it
What is going on here? How do I change to a directory with spaces via Terminal.app ? Here is the context info: uname...
Read more >How to cd to a directory with a name containing spaces in bash?
You can use the Tab key after pressing the first few characters (this will then "fill in" the rest of the folder for...
Read more >Directory.SetCurrentDirectory(String) Method (System.IO)
The path to which the current working directory is set. ... NET Core versions older than 2.1: path is a zero-length string, contains...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Closing this.
With the merger of #643 this should be fixed.