Issue importing a .STL file
The file is getting created with no errors, but when I open it it’s empty. I’ve also tried this with a .step and a solid edge .par file, same result.
static void OpenSTLFile()
{
string stlPath = @”C:\Temp\Flange.stl”;
string invPath = @”C:\Temp\NewFlange.ipt”;
string strCLSld = “{81CA7D27-2DBE-4058-8188-9136F85FC859}”;
ApplicationAddIns oAddins = oApp.ApplicationAddIns;
TranslatorAddIn oTransAddin = (TranslatorAddIn)oAddins.ItemById[strCLSld];
oTransAddin.Activate();
TransientObjects otransObjects = oApp.TransientObjects;
DataMedium oFile = otransObjects.CreateDataMedium();
oFile.FileName = stlPath;
TranslationContext oContext = otransObjects.CreateTranslationContext();
oContext.Type = IOMechanismEnum.kDataDropIOMechanism;
NameValueMap oOptions = otransObjects.CreateNameValueMap();
oOptions.Value[“SaveComponentDuringLoad”] = false;
oOptions.Value[“SaveLocationIndex”] = 0;
oOptions.Value[“ComponentDestFolder”] = “”;
oOptions.Value[“ImportUnit”] = 1;
oOptions.Value[“ImportColor”] = true;
oOptions.Value[“ImportColorIndex”] = 0;
object sourceObj = null;
oTransAddin.Open(oFile, oContext, oOptions, out sourceObj);
Document NewDoc = (Document)sourceObj;
NewDoc.SaveAs(invPath, false);
}
Read more here: Source link
