I am trying to access a java program MELTING 5 in R using the rjava package.
I can do it using the system function as follows using the batch file.
path <- "path/to/melting.bat"
sequence = "GTCGTATCCAGTGCAGGGTCCGAGGTATTCGCACTGGATACGACTTCCAC"
hybridisation.type = "dnadna"
OligomerConc = 5e-8
Sodium = 0.05
command=paste("-S", sequence,
"-H", hybridisation.type,
"-P", OligomerConc,
"-E", paste("Na=", Sodium, sep = ""))
system(paste("melting.bat", command))
I am trying to do the same using a wrapper, following the steps in hellowjavaworld without any success.
.jaddClassPath('path/to/melting5.jar')
main <- .jnew("melting/Main")
out <- .jcall(obj = main, returnSig = "V", method = "main", .jarray(list(), "java/lang/String"),
argument = command)
The java code in melting/Main.java in the melting5.jar that I am trying to access is as follows.
package melting;
import java.text.NumberFormat;
import melting.configuration.OptionManagement;
import melting.configuration.RegisterMethods;
import melting.methodInterfaces.MeltingComputationMethod;
import melting.nearestNeighborModel.NearestNeighborMode;
/**
* The Melting main class which contains the public static void main(String[] args) method.
*/
public class Main {
// private static methods
/**
* Compute the entropy, enthalpy and the melting temperature and display the results.
* #param args : contains the options entered by the user.
* #param OptionManagement optionManager : the OptionManegement which allows to manage
* the different options entered by the user.
*/
private static ThermoResult runMelting(String [] args, OptionManagement optionManager){
try {
ThermoResult results =
getMeltingResults(args, optionManager);
displaysMeltingResults(results);
return results;
} catch (Exception e) {
OptionManagement.logError(e.getMessage());
return null;
}
}
/**
* Compute the entropy, enthalpy and melting temperature, and return
* these results.
* #param args options (entered by the user) that determine the
* sequence, hybridization type and other features of the
* environment.
* #param optionManager the {#link
* melting.configuration.OptionManagement
* <code>OptionManagement</code>} which
* allows the program to manage the different
* options entered by the user.
* #return The results of the Melting computation.
*/
public static ThermoResult getMeltingResults(String[] args,
OptionManagement optionManager)
{
NumberFormat format = NumberFormat.getInstance();
format.setMaximumFractionDigits(2);
// Set up the environment from the supplied arguments and get the
// results.
Environment environment = optionManager.createEnvironment(args);
RegisterMethods register = new RegisterMethods();
MeltingComputationMethod calculMethod =
register.getMeltingComputationMethod(environment.getOptions());
ThermoResult results = calculMethod.computesThermodynamics();
results.setCalculMethod(calculMethod);
environment.setResult(results);
// Apply corrections to the results.
results = calculMethod.getRegister().
computeOtherMeltingCorrections(environment);
environment.setResult(results);
return environment.getResult();
}
/**
* displays the results of Melting : the computed enthalpy and entropy (in cal/mol and J/mol), and the computed
* melting temperature (in degrees).
* #param results : the ThermoResult containing the computed enthalpy, entropy and
* melting temperature
* #param MeltingComputationMethod calculMethod : the melting computation method (Approximative or nearest neighbor computation)
*/
private static void displaysMeltingResults(ThermoResult results)
{
NumberFormat format = NumberFormat.getInstance();
format.setMaximumFractionDigits(2);
MeltingComputationMethod calculMethod =
results.getCalculMethod();
double enthalpy = results.getEnthalpy();
double entropy = results.getEntropy();
OptionManagement.logInfo("\n The MELTING results are : ");
if (calculMethod instanceof NearestNeighborMode){
OptionManagement.logInfo("Enthalpy : " + format.format(enthalpy) + " cal/mol ( " + format.format(results.getEnergyValueInJ(enthalpy)) + " J /mol)");
OptionManagement.logInfo("Entropy : " + format.format(entropy) + " cal/mol-K ( " + format.format(results.getEnergyValueInJ(entropy)) + " J /mol-K)");
}
OptionManagement.logInfo("Melting temperature : " + format.format(results.getTm()) + " degrees C.\n");
}
// public static main method
/**
* #param args : contains the options entered by the user.
*/
public static void main(String[] args) {
OptionManagement optionManager = new OptionManagement();
if (args.length == 0){
optionManager.initialiseLogger();
optionManager.readMeltingHelp();
}
else if (optionManager.isMeltingInformationOption(args)){
try {
optionManager.readOptions(args);
} catch (Exception e) {
OptionManagement.logError(e.getMessage());
}
}
else {
runMelting(args, optionManager);
}
}
}
How to pass arguments in command to public static void main in java jar?
Over at https://github.com/hrbrmstr/melting5jars I made a pkg wrapper for the MELTING 5 jar (melting5.jar) and also put the Data/ directory in it so you don't have to deal with jar-file management. It can be installed via devtools::install_github("hrbrmstr/melting5jars"),
BEFORE you load that library, you need to set the NN_PATH since the Data/ dir is not where the jar expects it to be by default and you may run into issues setting it afterwards (YMMV).
NOTE: I don't work with this Java library and am not in your field, so please double check the results with the command-line you're used to running!
So, the first things to do to try to get this to work are:
Sys.setenv("NN_PATH"=system.file("extdata", "Data", package="melting5jars"))
library(melting5jars) # devtools::install_github("hrbrmstr/melting5jars")
Now, one of the cooler parts of rJava is that you get to work in R (code) if you want to vs Java (code). We can recreate the core parts of that Main class right in R.
First, get a new melting.Main object and a new OptionManagement object just like the Java code does:
melting <- new(J("melting.Main"))
optionManager <- new(J("melting.configuration.OptionManagement"))
Next, we setup your options. I left Sodium the way it is just to ensure I didn't mess anything up.
Sodium <- 0.05
opts <- c(
"-S", "GTCGTATCCAGTGCAGGGTCCGAGGTATTCGCACTGGATACGACTTCCAC",
"-H", "dnadna",
"-P", 5e-8,
"-E", paste("Na=", Sodium, sep = "")
)
Now, we can call getMeltingResults() from that Main class directly:
results <- melting$getMeltingResults(opts, optionManager)
and then perform the same calls on those results:
calculMethod <- results$getCalculMethod()
enthalpy <- results$getEnthalpy()
entropy <- results$getEntropy()
if (.jinstanceof(calculMethod, J("melting.nearestNeighborModel.NearestNeighborMode"))) {
enthalpy <- results$getEnergyValueInJ(enthalpy)
entropy <- results$getEnergyValueInJ(entropy)
}
melting_temperature <- results$getTm()
enthalpy
## [1] -1705440
entropy
## [1] -4566.232
melting_temperature
## [1] 72.04301
We can wrap all that up into a function that will make it easier to call in the future:
get_melting_results <- function(opts = c()) {
stopifnot(length(opts) > 2) # a sanity check that could be improved
Sys.setenv("NN_PATH"=system.file("extdata", "Data", package="melting5jars"))
require(melting5jars)
melting <- new(J("melting.Main"))
optionManager <- new(J("melting.configuration.OptionManagement"))
results <- melting$getMeltingResults(opts, optionManager)
calculMethod <- results$getCalculMethod()
enthalpy_cal <- results$getEnthalpy()
entropy_cal <- results$getEntropy()
enthalpy_J <- entropy_J <- NULL
if (.jinstanceof(calculMethod, J("melting.nearestNeighborModel.NearestNeighborMode"))) {
enthalpy_J <- results$getEnergyValueInJ(enthalpy_cal)
entropy_J <- results$getEnergyValueInJ(entropy_cal)
}
melting_temp_C <- results$getTm()
list(
enthalpy_cal = enthalpy_cal,
entropy_cal = entropy_cal,
enthalpy_J = enthalpy_J,
entropy_J = entropy_J,
melting_temp_C = melting_temp_C
) -> out
class(out) <- c("melting_res")
out
}
That also has separate values for enthalpy and entropy depending on the method result.
We can also make a print helper function since we classed the list() we're returning:
print.melting_res <- function(x, ...) {
cat(
"The MELTING results are:\n\n",
" - Enthalpy: ", prettyNum(x$enthalpy_cal), " cal/mol",
{if (!is.null(x$enthalpy_J)) paste0(" (", prettyNum(x$enthalpy_J), " J /mol)", collapse="") else ""}, "\n",
" - Entropy: ", prettyNum(x$entropy_cal), " cal/mol-K",
{if (!is.null(x$entropy_J)) paste0(" (", prettyNum(x$entropy_J), " J /mol-K)", collapse="") else ""}, "\n",
" - Meltng temperature: ", prettyNum(x$melting_temp_C), " degress C\n",
sep=""
)
}
(I made an assumption you're used to seeing the MELTING 5 command line output)
And, finally, re-run the computation:
Sodium <- 0.05
opts <- c(
"-S", "GTCGTATCCAGTGCAGGGTCCGAGGTATTCGCACTGGATACGACTTCCAC",
"-H", "dnadna",
"-P", 5e-8,
"-E", paste("Na=", Sodium, sep = "")
)
res <- get_melting_results(opts)
res
## The MELTING results are:
##
## - Enthalpy: -408000 cal/mol (-1705440 J /mol)
## - Entropy: -1092.4 cal/mol-K (-4566.232 J /mol-K)
## - Meltng temperature: 72.04301 degress C
str(res)
## List of 5
## $ enthalpy_cal : num -408000
## $ entropy_cal : num -1092
## $ enthalpy_J : num -1705440
## $ entropy_J : num -4566
## $ melting_temp_C: num 72
## - attr(*, "class")= chr "melting_res"
You should be able to use the above methodology to wrap other components (if any) in the MELTING library.
package modifiedlines;
import edu.nyu.cs.javagit.api.DotGit;
import edu.nyu.cs.javagit.api.JavaGitConfiguration;
import edu.nyu.cs.javagit.api.JavaGitException;
import edu.nyu.cs.javagit.api.WorkingTree;
import edu.nyu.cs.javagit.api.commands.GitLogResponse;
import edu.nyu.cs.javagit.api.commands.GitStatus;
import edu.nyu.cs.javagit.api.commands.GitStatusOptions;
import edu.nyu.cs.javagit.api.commands.GitStatusResponse;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
*
* #
author aryan000
*/
public class UseGit {
private static File repositoryDirectory;
private static DotGit dotGit;
public static void main(String s[]) throws JavaGitException, IOException
{
File f = new File("C:\\Program Files\\Git\\bin\\git.exe");
if(!f.exists())
{
System.out.println("does not exist");
}
else
System.out.println("exists at " + f.getPath());
JavaGitConfiguration.setGitPath("C:\\Program Files\\Git\\bin");
System.out.println("Git version : " + JavaGitConfiguration.getGitVersion());
// repositoryDirectory = new File("/home/aryan000/Desktop/retrofit");
repositoryDirectory = new File("/home/aryan000/Desktop/changeprone/changeprone");
System.out.println("Git Repository Location : " + repositoryDirectory.getAbsolutePath());
//get the instance of the dotGit Object
dotGit = DotGit.getInstance(repositoryDirectory);
// System.out.println("checking what i have got ");
// GitLogResponse.CommitFile com ;
// com = (GitLogResponse.CommitFile) dotGit.getLog();
//
// System.out.println(com);
WorkingTree wt = dotGit.getWorkingTree();
File workingTreePath = wt.getPath();
GitStatus gitStatus = new GitStatus();
GitStatusResponse status = gitStatus.status(workingTreePath);
System.out.println("status is : " + status);
File anotherFileDir = new File("/home/aryan000/Desktop/retrofit/test.txt");
GitStatusOptions options = new GitStatusOptions();
options.setOptOnly(true);
status = gitStatus.status(workingTreePath);
System.out.println("status is : " + status);
System.out.println("----- Print log to see our commit -----");
for (GitLogResponse.Commit c : dotGit.getLog()) {
System.out.println("commit id is : " + c.getSha());
System.out.println(" commit message is : " + c.getMessage());
System.out.println(" author of the commit is : " + c.getAuthor());
System.out.println(" date modified is : " + c.getDateString());
System.out.println(" number of files changed is : " + c.getFiles());
List<GitLogResponse.CommitFile> store = c.getFiles();
if(store!=null)
System.out.println("the number of files changed is : " + store.size());
System.out.println("list of files changed is : " + c.getFilesChanged());
System.out.println("total number of additions : " + c.getLinesDeleted());
System.out.println("total number of merger : " + c.getMergeDetails());
}
// for(GitLogResponse.CommitFile c : dotGit.getLog())
}
}
Output is shown as :
Exception in thread "main" edu.nyu.cs.javagit.api.JavaGitException: 100002: Invalid path to git specified. { path=[C:\Program Files\Git\bin] }
at edu.nyu.cs.javagit.api.JavaGitConfiguration.setGitPath(JavaGitConfiguration.java:220)
at edu.nyu.cs.javagit.api.JavaGitConfiguration.setGitPath(JavaGitConfiguration.java:247)
at modifiedlines.UseGit.main(UseGit.java:40)
Caused by: edu.nyu.cs.javagit.api.JavaGitException: 100002: Invalid path to git specified.
at edu.nyu.cs.javagit.api.JavaGitConfiguration.determineGitVersion(JavaGitConfiguration.java:81)
at edu.nyu.cs.javagit.api.JavaGitConfiguration.setGitPath(JavaGitConfiguration.java:217)
... 2 more
Java Result: 1
My query is how to find git logs and the files changed due to a particular commit using a Java Program.
Can any 1 help me in this.
Please See : This code is working fine in Ubuntu i.e. no Path problem still I am unable to get the files changed during a commit. It is give me a List as a null.
This bug was opened a long time ago and just fixed it. Please give it a try , use master branch please, and let me know if it works for you.
In this case I am creating a plugin to learn, I need to know the following things.
What I want to do is to establish points on the map and at these points when another command will fall lightning.
1- For example: /thor setpoint 1, 2, 3, 4...
And in config created...
Lightning:
1:
x:
y:
z:
2:
x:
y:
z:
3... 6, 14..
The next three commands.
/thor delpoint 1, 2, 3... = Deleted point ID
/launch all = Launch all points
/launch ID = Only launch id
For now I managed to fall into a coordinate, single configuration file.
Thanks in advance
Main:
package me.alexbanper.thorproject.plugin;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
//import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public class ThorProject extends JavaPlugin implements Listener {
public void onEnable(){
saveDefaultConfig();
}
public void onDisable(){
}
public boolean onCommand(CommandSender enviar, Command comando, String commandLabel, String[] args){
Player player = (Player) enviar;
if(enviar instanceof Player){
if(commandLabel.equalsIgnoreCase("trueno")){
if(player.hasPermission("trueno.comando")){
if(args.length == 0){
player.sendMessage(col("&aUtiliza:"));
player.sendMessage(col("&6/trueno iniciarahora &5Inicia los truenos"));
player.sendMessage(col("&6/trueno iniciartiempo SEGUNDOS &5Inicia con segundos"));
player.sendMessage(col("&6/trueno setpoint &5establece un punto"));
}else if(args.length == 1){
if(args[0].equalsIgnoreCase("setpoint")){
this.getConfig().set("Config" + ".Thor" + ".X", player.getLocation().getBlockX());
this.getConfig().set("Config" + ".Thor" + ".Y", player.getLocation().getBlockY());
this.getConfig().set("Config" + ".Thor" + My".Z", player.getLocation().getBlockZ());
//this.getConfig().set("Config" + ".World", player.getLocation().getWorld());
saveConfig();
player.sendMessage(col("&aSpawnPoint 1 set!"));
player.sendMessage("X: " + getConfig().getInt("Config.Thor.X"));
player.sendMessage("Y: " + getConfig().getInt("Config.Thor.Y"));
player.sendMessage("Z: " + getConfig().getInt("Config.Thor.Z"));
player.sendMessage("World: " + getConfig().getString("Config.World"));
}else if(args[0].equalsIgnoreCase("setpoint2")){
this.getConfig().set("Config" + ".Thor2" + ".X", player.getLocation().getBlockX());
this.getConfig().set("Config" + ".Thor2" + ".Y", player.getLocation().getBlockY());
this.getConfig().set("Config" + ".Thor2" + ".Z", player.getLocation().getBlockZ());
//this.getConfig().set("Config" + ".World", player.getLocation().getWorld());
saveConfig();
player.sendMessage(col("&aSpawnPoint 2 Set!"));
player.sendMessage("X: " + getConfig().getInt("Config.Thor2.X"));
player.sendMessage("Y: " + getConfig().getInt("Config.Thor2.Y"));
player.sendMessage("Z: " + getConfig().getInt("Config.Thor2.Z"));
player.sendMessage("World: " + getConfig().getString("Config.World"));
}
}
}else{enviar.sendMessage(col("&cAcceso Denegado!"));}
}else if(commandLabel.equalsIgnoreCase("it")){
int x = getConfig().getInt("Config.Thor.X");
int y = getConfig().getInt("Config.Thor.Y");
int z = getConfig().getInt("Config.Thor.Z");
int x2 = getConfig().getInt("Config.Thor2.X");
int y2 = getConfig().getInt("Config.Thor2.Y");
int z2 = getConfig().getInt("Config.Thor2.Z");
//Object world = getConfig().get("Config" + ".World");
Location light = new Location(null, x, y, z);
Location light2 = new Location(null, x2, y2, z2);
Bukkit.getServer().getWorld("world").strikeLightningEffect(light);
Bukkit.getServer().getWorld("world").strikeLightningEffect(light2);
player.sendMessage("All correct!");
}
}else{enviar.sendMessage("Only Players!");}
return false;
}
public static String col(String msg){
return ChatColor.translateAlternateColorCodes('&', msg);
}
}
/trueno = /thor (I speak Spanish)
First of all, you need to save the world name too or you cannot get the location at all later. For all, make a call to get the keyset and iterate through all of the locations. (Be careful how you do this, make sure you are using the correct keys)
Delete the map of the key when you need to delete a location. Lastly, get the corresponding key when selecting a specific ID.
There are plenty of videos you can google to understand the behavior of Bukkit's YAMLConfigiration class, but most of them are absolutely horrible. I found one that isn't AS bad for you. It is for config files, but the YAMLConfig class behaves very similarly. (I plan on doing some of my own tutorials this summer, but I am going to be VERY careful with following java conventions and correct practice unlike most of these youtubers)
Bukkit Coding ~ Episode 5: Configuration: https://youtu.be/SBvrpmNDr74
As a side note, the bukkit forums are a better place for bukkit development than stack overflow.
http://bukkit.org/forums/
I want to use netapp manageability api using java.
By using that api I want to access remote systems storage.
How do I connect to remote system to and access storage details using api?
Any sample code to connect to remote system and access it??
Here is a answer.
But it gives only version and isclustered or not.
It do not gives details about volumelist.
import java.util.Iterator;
import java.util.List;
import com.netapp.nmsdk.client.ApiRunner;
import com.netapp.nmsdk.client.ApiTarget;
import com.netapp.nmsdk.client.ApiTarget.TargetType;
import com.netapp.nmsdk.client.ApiTarget.Protocol;
import com.netapp.nmsdk.dfm.api.event.*;
import com.netapp.nmsdk.dfm.api.event.EventListIterStartRequest;
import com.netapp.nmsdk.dfm.api.volume.VolumeInfo;
import com.netapp.nmsdk.dfm.api.volume.VolumeListInfoIterStartRequest;
import com.netapp.nmsdk.ontap.api.system.SystemGetVersionRequest;
import com.netapp.nmsdk.ontap.api.system.SystemGetVersionResponse;
public class RunStorage {
public void startStorage(){
System.out.println("in start storage class");
}
public static void main (String [] args){
//Attempt to connect to host and get basic info.
String myip= "192.168.x.xx";
String url = "https://"+myip;
Protocol protocol = Protocol.INSECURE_HTTPS;
try {
System.out.println("url is .." + url);
ApiRunner apirunner = new ApiRunner(ApiTarget.builder()
.withHost(myip)
.withUserName("username")
.withPassword("password")
.withTargetType(TargetType.FILER)
.useProtocol(protocol)
.build()
);
// to get version of device
SystemGetVersionRequest vq = new SystemGetVersionRequest();
SystemGetVersionResponse vr = apirunner.run(vq);
System.out.println("System version is .. " + vr.getVersion());
// ****************** end of version *****************
// To check wheather systems is clustered or not
if (vr.isClustered() != null && vr.isClustered()){
System.out.println("storage is clustered");
}
else {
System.out.println("Storage is in 7 Mode");
}
//********************** end of cluster **********************
// To get List of volumes
VolumeListInfoIterStartRequest volumeListReq = new VolumeListInfoIterStartRequest();
System.out.println(volumeListReq);
Iterator<VolumeInfo> volumeIter = apirunner.iterate(volumeListReq,10);
System.out.println(volumeIter);
VolumeInfo volume ;
System.out.println("outside while .. " + volumeIter.toString());
while (volumeIter.hasNext()){
volume = volumeIter.next();
if(volume == null){
System.out.println("in if");
}
else {
System.out.println("in else");
}
System.out.println("Volume object is .. " + volume);
System.out.println("volume name is.. " + volume.getVolumeName());
System.out.println("extra .. " + volume.getAggregateName());
System.out.println("Type.. " + volume.getBlockType());
System.out.println("State .. " + volume.getVolumeState());
System.out.println("Total size .. " + volume.getVolumeSize());
System.out.println("Total used size .. " + volume.getVolumeFullThreshold());
}
// ********************* end of volume list ************
}
catch (Exception e){
e.printStackTrace();
System.out.println("Error in getting info");
}
}
}
my problem is:
i have made a 3D model with texture in Cinema 4d ( similiar to this one : http://preview.turbosquid.com/Preview/2011/03/30__13_54_17/space%20shuttle%206.jpgeec17db2-6651-453c-9d27-ea1908e3c7dfLarge.jpg )
Now i want to export it to my jMonkeyEngine to set it up in my scene and to animate it.
I tried to export my model as a .obj-file and load it into my projekt (just the .obj-file).
The result is that i have no textures! What do i wrong?
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
/**
* test
* #author normenhansen
*/
public class Main extends SimpleApplication {
public static void main(String[] args) {
Main app = new Main();
app.start();
}
#Override
public void simpleInitApp() {
//Modell laden
Spatial spaceShuttle =assetManager.loadModel("Models/test/space.obj");
//Skalieren
spaceShuttle.scale(0.005f, 0.005f, 0.005f);
//Szenenbaum erstellen
Node sceneNode = new Node("sceneNode");
Node geometryNode = new Node("geometryNode");
Node lightNode = new Node("lightNode");
sceneNode.attachChild(lightNode);
sceneNode.attachChild(geometryNode);
rootNode.attachChild(sceneNode);
//neue Elemente in den Baum Einfügen
geometryNode.attachChild(spaceShuttle);
DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(1,0,-2).normalizeLocal());
sun.setColor(ColorRGBA.White);
rootNode.addLight(sun);
}
#Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}
#Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
}
You're not doing anything wrong. C4D exports just the .obj, but no .mtl by default.
I know that's true for C4D R11.5 and R12, not sure about newer ones.
You'll can write a script to export the .mtl as well.
Here's a Python snippet for reference:
#save mtl
mcount = 0;
mtl = ''
for tag in op.GetTags():
if(tag.GetType() == 5616): #texture tag
mcount += 1
m = tag.GetMaterial()
mtl += 'newmtl '+clean(m.GetName())+'\n'
if(m[sy.MATERIAL_COLOR_COLOR]): mtl += 'Kd ' + str(m[sy.MATERIAL_COLOR_COLOR].x) + ' ' + str(m[sy.MATERIAL_COLOR_COLOR].y) + ' ' + str(m[sy.MATERIAL_COLOR_COLOR].z) + '\n'
if(m[sy.MATERIAL_SPECULAR_COLOR]): mtl += 'Ks ' + str(m[sy.MATERIAL_SPECULAR_COLOR].x) + ' ' + str(m[sy.MATERIAL_SPECULAR_COLOR].y) + ' ' + str(m[sy.MATERIAL_SPECULAR_COLOR].z) + '\n'
if(m[sy.MATERIAL_SPECULAR_BRIGHTNESS]): mtl += 'Ns ' + str(m[sy.MATERIAL_SPECULAR_BRIGHTNESS]) + '\n'
if(m[sy.MATERIAL_TRANSPARENCY_BRIGHTNESS]): mtl += 'd ' + str(m[sy.MATERIAL_TRANSPARENCY_BRIGHTNESS]) + '\n'
if(m[sy.MATERIAL_COLOR_SHADER]): mtl += 'map_Kd ' + str(m[sy.MATERIAL_COLOR_SHADER][sy.BITMAPSHADER_FILENAME]) + '\n'
if(m[sy.MATERIAL_TRANSPARENCY_SHADER]): mtl += 'map_d ' + str(m[sy.MATERIAL_COLOR_SHADER][sy.BITMAPSHADER_FILENAME]) + '\n'
if(m[sy.MATERIAL_BUMP_SHADER]): mtl += 'map_bump ' + str(m[sy.MATERIAL_BUMP_SHADER][sy.BITMAPSHADER_FILENAME]) + '\n'
mtl += 'illum 0\n\n\n'#TODO: setup the illumination, ambient and optical density
mtl = '# Material Count: '+str(mcount)+'\n'+mtl
file = open(mtlPath,'w')
file.write(mtl)
file.close()
It's part of this old script, but note this is with the old R11.5 C4D Python API, the syntax is a bit different now, so use updated documentation and the above more as a general direction on what properties to look for.
A 'codeless' alternative is to bring your model into a different 3D package which properly exports .obj (and .mtl) like Blender for example. You will need to find an intermediary format that will preserve the material data (you can try 3DS,Collada, FBX I think) but be aware of the difference in units and coordinate systems. Hopefully the model features you need are preserved in the file format you export from C4D and properly imported back into the other 3D package.