I have the following GDAL script using the OSGeo console that i have tested for one image, that I want to change now to run over every image in one folder and output to another folder?
Edit: the code I posted was a test I ran on one image to check visual quality. I was happy with the visual quality after compressing my test image. I now want to apply the script to approx. 1000 images located in one folder and output to another folder.
Edit: i am not sure why I have received a downvote for asking a question in a straightforward manner? I have checked numerous other posts on SO and reddit and have not been able to get any process to work within the QGIS OsGeo framework and would value some advice.
gdal_translate -co COMPRESS=JPEG -co PHOTOMETRIC=YCBCR -co TILED=YES "D:\split outputs\raster_compression test\EQ_GLNG_Photo_2018_MGA550.tif" "D:\split outputs\raster_compression test\0001_JPEG.tif" -scale -ot Byte
In the QGIS python console something like the following should work
This expects your input and output folders to exist, and it expects that the input folder contains all tif files as a child (not in sub folders)
import os
from osgeo import gdal
input_folder = 'path_to_input'
output_folder = 'path_to_output'
options = gdal.TranslateOptions(
outputType=gdal.GDT_Byte,
scaleParams=[''],
creationOptions=['COMPRESS=JPEG', 'PHOTOMETRIC=YCBCR', 'TILED=YES']
)
for entry in os.listdir(input_folder):
if entry.endswith('.tif'):
gdal.Translate(
os.path.join(output_folder, entry),
os.path.join(input_folder, entry),
options=options
)
Related
I'm working in Jupyter Notebook. I've installed music21, musescore, set the xml path as below:
us = environment.UserSettings()
us['musicxmlPath'] ='Applications/musescore.app'
I've also run config, and see that musescore is being detected by music21. However, when I use the show method, I get the following error:
SubConverterFileIOException: png file of xml not found. Or file >999 pages?
Any help is appreciated. Thanks!
An .app file is a directory. Inside the MuseScore.app directory is a bin directory and a file called mscore -- that's the actual name in the path. It'd be much easier to run python -m music21.configure and let the automatic configuration program take care of it.
Are you sure that file is exist?
try changing 'Applications/musescore.app' to '/Applications/musescore.app'
Hope that helps
I found a answer from here wrote by GaetanBaert,It works well and now I can use show method.
He said that "you should change os.system(musescoreRun) line 891 of subconverters.py by subprocess.run(musescoreRun). You need also to import subprocess at the start of subconverters.py."
I am running Vanilla AutoCAD 2017
The accoreconsole.exe will start but and show the example Screen and will appears to run commands, although i am unaware of a way to open a file directly from core console so i cant really do anything with it.
Methods attempted
1. Script Pro 2.0:
From https://knowledge.autodesk.com/support/autocad/downloads/caas/downloads/content/autodesk-customization-conversion-tools.html
Script pro executes scripts successfully when using AutoCAd But then Fails when i switch to Core Console
It generates a log file that reads: Error while reading log file for C:\Users\Documents\TEST\ARCH01_FIRST FLOOR PLAN - AREA C.dwg
2.Auto Lisp
From AutoCAD using an Auto Lisp command i found on House of BIM. The command works and i tested several scripts which i first tested using the Run Script Button in AutoCad and they worked, but not when i used core console.
This generated a Temp file called accc34642 which reads m_kernelList still has 1 entry
/i core console flashes and then disappears
/I core console opens a new file from the Qnew Template file path
This seems to happen no matter whats after that in the lisp statement.
Then OPEN command in core console doesn't return a prompt or an error, it just returns twice and does nothing.
Typing in a file path generates an error
3.Widows batch files
I have only used one of these in the past successfully but i checked the ones i found a couple different websites and still no luck on getting the scripts to execute.
I also tried all this from different File Paths
The main idea of AutoCAD Console is to process 1 file and exit. That's also important to avoid memory fragmentation and errors when you process multiple files in a single instance of accoreconsole.exe
So, as already mentioned, consider a workflow where each instance process a single file and then exit. You may even consider multiple instances of accoreconsole to process multiple files at once.
Wed0,
to get started with working with accoreconsole, here are a couple links that will help you:
1) http://adndevblog.typepad.com/autocad/2012/04/getting-started-with-accoreconsole.html
2) http://through-the-interface.typepad.com/through_the_interface/2012/02/the-autocad-2013-core-console.html
for the second article, Kean goes into quite a bit of detail, but I don't especially like his approach with using .bat files. It is much nicer to use a programming language like C#.
As for opening files, it actually is possible!
I recently discovered a VERY fast method of processing dwg files using accorconsole (or AutoCAD if that is what you prefer). For example, running a search and replace operation of dbtext and mtext on a batch of dwg files runs at around 15 drawings/second on a single process. Setting up 5 or 6 in parallel will process close to 5000 drawings/minute! I thought I would share this with the community as this discovery has been a game-changer for my company when it comes to processing large batches of dwg files.
For this you have to use the .NET API(or C++, etc). I did all the code for processing in C#, and the only 2 lines in the lisp script file is to NETLOAD my dll and call the command that does the processing.
Turns out, you can work on multiple dwg files in the same instance of accoreconsole. The idea here is to just load the dwg database without actually opening the drawing (takes ~70ms), manipulate the database, then save it. For the i/ switch, you can use any dummy drawing file as it will have no effect on your batch. Then in C# in your command method, you would do something like this:
string[] dwgFiles = Directory.GetFiles("C:\\MyDWGFiles");
foreach(string drawingFilePath in dwgFiles)
{
using(Database database = new Database(false, true))
{
database.ReadDwgFile(drawingFilePath, FileShare.ReadWrite,
true String.Empty);
using(Transaction transaction =
database.TransactionManager.StartTransaction())
{
//DO STUFF HERE
transaction.Commit();
database.SaveAs(drawingFilePath, DwgVersion.Current);
}
}
}
Let me know if you have any questions or need more detail,
I don't believe it is possible to open files from within core console. I am relatively certain core console has to be initialized with the path as an argument of the drawing you wish it to open. Once it is open you can then do work with that file. So, you would essentially have to open a single instance of core console for each file you want to do work on.
Hope that helps.
The best way as drive AutoCAD commands as dwg files is use the concept mencioned by "Autodesk Knowledge Network": Out-of-Process .NET
a. https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-NET/files/GUID-C8C65D7A-EC3A-42D8-BF02-4B13C2EA1A4B-htm.html),
and this alternative is supported by Autodesk; the accoreconsole is not.
With this features, you may execute AutoCAD software, open Projects, batch iterates on files and manipulate data. Recently, I developed one plugin that has two requirements:
b. be executed without user-intervention and,
c. interates on all Dwg files to execute a process per-file;
Like link above, I instantiated AutoCAD and send commands like a lisp sintaxe to call the customized command (as "("CUSTOM_CMD", "PARAMS1", "PARAMS2" ...)" );
My custom command was like this:
[CommandMethod("CUSTOM_CMD")]
public static void CustomCmd
{
//stuff iterate on DWGs
}
3.Comments: It's importante to use Thread Safe Collection (for example ConcurrentBag) to memory Dwg Collection to ensure non interference between Next Moving contiguous Dwgs iteraction's running.
How do I create a batch file that wil automatically install office,java and photoshop without a box asking hundreds of preferences?
for example:
#ECHO OFF
start J:\Batch\test.exe
But if I do that it asks: Select setup language
What is the code for passing that box and automatically select English? I searched on the web but I couldn't find it. Does anyone know it?
Here is the exe file I'm testing: http://pxc-coding.com/downloads/tweaks-for-skype/Tweaks-for-Skype-1.0.0.2-Setup.exe
I' not going to download and run an unknown program.
But you can try this:
1) run the program
2) note every answer
3) put those answers into a textfile (each answer in an own line, no empty lines - except you just hit "enter" to an answer)
4) run test.exe <answers.txt
once it works, you can distribute answers.txt with your package.
I am trying to use a MEL script to load ANIMATION.MA file that references CHARACTER_RIG.MA. The CHARACTER_RIG.MA and ANIMATION.MA files are produced by someone else and supplied to me. The ANIMATION.MA is looking for N:/Project/Maya//char/character/CHARACTER_RIG.MA
If I open ANIMATION.MA from Maya, or use the equivalent MEL command I always get prompted with:
"Reference File Not Found"
Reference File Not Found: N:/Project/Maya//char/character/CHARACTER_RIG.MA.
[Abort File Read] [Skip] [Browse...] [Retry]
If I tap browse, and select the CHARACTER_RIG.MA then it opens perfectly. I can see it created a reference in the Reference Editor that has the Unresolved Path (N:/...) , the Resolved Path (/my/path) and the namespace and the namespaceRN.
My question is, how do I do the equivalent of the "Browse..." from MEL? I tried pre-creating a reference, but it doesn't let me set the unresolved path, so when I load the ANIMATION.MA it keeps prompting in MAYA.
file -f -options "v=0" -typ "mayaAscii" -o "/Source/project/assets/anims/ANIMATION.MA"
If you know the directory where the file is, then you can use the dirmap command. The command dirmap allows you to remap directory structures if your disk configuration changes. So in this case it would look like:
dirmap -en true;
dirmap -m "N:/Project/Maya//char/character" "/my/path";
Possibly more manageable if you have lots of mappings to do especially when moving form a windows machine to a *nix one. However it is much more useful to define your project structure because then things just work when you move, tough this may not be the best of choice for shared assets.
I ended up finding several solutions:
Rename the RIG.MA file to match the filename in ANIM.MA (they were different in my case) and put it in one of the search or project folders that MAYA uses and it will automatically find it.
or
Programatically through code (or manually) edit the ANIM.MA file to remap the file/folder of the RIG.MA to where you want to load it from. Note: You
also need to remap any other files, such as textures. I did this with
perl -pi -e 's/\Qold-path\E/\Qnew-path\E/g' ANIMATION.MA
HTH someone else.
Quick and easy, File, Project, Set and select the folder where meshes or whatever it is.
Is there a Notepad++ plugin out there that automatically combines all currently opened files into a single file?
Update: Yes, I am very aware of copy and paste :) I'm working with lots of files, and I want a solution that makes this step in the process a little bit faster than several dozen copy and pastes.
I'm aware of utilities for combining files, but I want the convenience of combining specifically the files that are currently opened in my text editor.
If there isn't a plugin out there already, I'll write one myself; I was just wondering if it exists already to save me the time of developing one.
I used the following command in DOS prompt to do the merge for me:
for %f in (*.txt) do type "%f" >> output.txt
It is fast and it works. Just ensure that all the files to be merge are in the same directory from where you execute this command.
http://www.scout-soft.com/combine/
Not my app, but this plug in lets you combine all open tabs into one file.
I installed the Python Script plugin and wrote a simple script:
console.show()
console.clear()
files = notepad.getFiles()
notepad.new()
newfile = notepad.getCurrentFilename()
for i in range(len(files) - 1):
console.write("Copying text from %s\n" % files[i][0])
notepad.activateFile(files[i][0])
text = editor.getText()
notepad.activateFile(newfile)
editor.appendText(text)
editor.appendText("\n")
console.write("Combine Files operation complete.")
It looks at all the files currently opened in Notepad++ and adds them to a new file. Does exactly what I need.