Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
I am using JLink to export all parts in an assembly to STL files. During this, I also create an XML file with the position and rotation of each part in the assembly. (Not all parts export currently but I'm ignoring that for now). I am then importing the parts into another application. This is pretty close to working, but I am running into an issue where things seem kind of "inside out". I obviously can't post images to show what this looks like, but here is the code I'm using to store the position. Can anyone see anything I might be missing that is causing this? When I do the export to STL, I do not specify a coordinate system such as by using:
pfcModel.STLBinaryExportInstructions_Create().SetCsysName()
Here is the code for storing the position information.
public class PositionInAssembly { private String partName; private String assemblyName; private String partType; private int id; private Point3D origin; private Vector3D xAxis; private Vector3D yAxis; private Vector3D zAxis; public PositionInAssembly(String assemblyName, ComponentFeat componentFeat) throws jxthrowable { this.assemblyName = assemblyName; this.partName = componentFeat.GetModelDescr().GetFileName(); this.id = componentFeat.GetId(); this.origin = componentFeat.GetPosition().GetOrigin(); this.xAxis = componentFeat.GetPosition().GetXAxis(); this.yAxis = componentFeat.GetPosition().GetYAxis(); this.zAxis = componentFeat.GetPosition().GetZAxis(); if (componentFeat.GetModelDescr().GetType() == ModelType.MDL_PART) partType = "part"; else if (componentFeat.GetModelDescr().GetType() == ModelType.MDL_ASSEMBLY) partType = "assembly"; else partType = componentFeat.GetModelDescr().GetType().getCipTypeName(); } public String GetXML() { String x = ""; String y = ""; String z = ""; String o = ""; String coordinatesFormat = "%.5f,%.5f,%.5f"; String parentId = ""; try { x = String.format(coordinatesFormat, xAxis.get(0), xAxis.get(1), xAxis.get(2)); y = String.format(coordinatesFormat, yAxis.get(0), yAxis.get(1), yAxis.get(2)); z = String.format(coordinatesFormat, zAxis.get(0), zAxis.get(1), zAxis.get(2)); o = String.format(coordinatesFormat, origin.get(0), origin.get(1), origin.get(2)); } catch (com.ptc.cipjava.jxthrowable jxthrowable) { jxthrowable.printStackTrace(); } return String.format("<%s name=\"%s\" parent=\"%s\" id=\"%s\">" + "<origin>%s</origin><x>%s</x><y>%s</y><z>%s</z></%s>", partType, partName.replaceAll("[^a-zA-Z0-9_\\-\\.\\s]", "_"), assemblyName.replaceAll("[^a-zA-Z0-9_\\-\\.\\s]", "_"), id, o, x, y, z, partType); } }
Solved! Go to Solution.
In case anyone else runs into this, my problem was that +X in Creo was -X in the application I was importing the STLs into. I had to make sure to set the X coordinate to negative as well as the entire X vector (for rotation). I was apparently not properly negating it in one place or another and that was my problem.
In case anyone else runs into this, my problem was that +X in Creo was -X in the application I was importing the STLs into. I had to make sure to set the X coordinate to negative as well as the entire X vector (for rotation). I was apparently not properly negating it in one place or another and that was my problem.