Reply
Solved! Go to solution

Set SESTL.ini

Hello developers!

I am almost done with my plugin, just a short bug I found while testing:

Currently I am exporting the model in active document as a stl file

(saveCopyas(C:\\.....stl))

And that works perfectly fine! But if you use "save as" with the GUI and set "stl" you have options (like milimeter, inches, binary...)

 

How can I set this options?

 

(I heard that those options are saved in program/SESTL.ini, but I want to avoid changing files in the installation directory, since users doesnt always have rights to do so.. )

 

Would be great if someone has a solution for my situation!

 

9 REPLIES

Re: Set SESTL.ini

To the SolidEdge Developers:

Where do you get to units of STL Export wenn the function saveCopyAs().. is called? Because it doesnt seem like the export is using SESTL.ini

 

If I do: GUI->saveastranslated->Stl->options->mm

then after I am using my script, which calls savecopyas(c:\.....stl) the stl file is exported in mm although SESTL.ini says "inch"

Re: Set SESTL.ini

Normally, when you save a model as STL and change the options, the SESTL.ini file gets overwritten and then the model is saved (tested in ST8).

So you should change this file before exporting to STL.

I can't believe that the SESTL.ini file shows a different option than the one you are using during export...

Re: Set SESTL.ini

This probably isn't much help to you but I can confirm the same behaviour on my machine.  I also manually changed the units it the sestl.ini file, but again it was overridden by the dialog box.

 

This seems strange as the help documentation states;

 

SESTL.ini file

The SESTL.ini file, found in the Solid Edge Program folder, is used to store the settings defined on the STL Import Options and STL Export Options dialog boxes. When you make a change to a parameter in the dialog box, a new value is saved to the SESTL.ini file. You can use a text editor, such as notepad, to set these parameters. However, if you edit this file, use extreme caution in setting these parameters. Errors made to this file can adversely affect the quality of the translation. The following is a list of parameters found in the SESTL.ini file.

 

 

You could try searching the registry for 'STL' 'mm' 'millimeter' or 'inch' on the off chance there's something there.

Re: Set SESTL.ini

I also searched the registry, but could not find anything. My suggestion is to write the STL file directly through code and then save the document as STL.

'----------------------------------------------------------------------
' PAR: Export the active part document to STL.
'----------------------------------------------------------------------
' Get the Solid Edge "Program" folder
Dim objType As Type = Type.GetTypeFromProgID("SolidEdge.InstallData")
Dim objInstData As SEInstallDataLib.SEInstallData = Activator.CreateInstance(objType)
Dim strProgFolder As String = objInstData.GetInstalledPath()
Marshal.ReleaseComObject(objInstData)
objInstData = Nothing
' Check, if a backup of SESTL.ini already exists and create one, if not
If IO.File.Exists(strProgFolder & "\SESTL.ini") AndAlso _
  Not IO.File.Exists(strProgFolder & "\SESTL_ORIG.ini") Then
  IO.File.Copy(strProgFolder & "\SESTL.ini", strProgFolder & "\SESTL_ORIG.ini")
End If

' Create a new SESTL.ini file with the desired units and tolerance values
Using sw As IO.StreamWriter = IO.File.CreateText(strProgFolder & "\SESTL.ini")
  sw.WriteLine("[Options]")
  sw.WriteLine("Memory Needed Per Native Element = 100000")
  sw.WriteLine("Memory Needed Per Foreign Element = 10000")
  sw.WriteLine("")
  sw.WriteLine(";Import Units Values can be Inch, Millimeter, or Meter")
  sw.WriteLine("Import Units=Millimeter")
  sw.WriteLine("Import Make Base Feature=On")
  sw.WriteLine("")
  sw.WriteLine(";Export Units Values can be Inch or Millimeter")
  sw.WriteLine("Export Units=Millimeter")
  sw.WriteLine("; The decimal delimiter for the tolerance and angle values MUST be a '.'")
  sw.WriteLine("Export Tolerance Value=0.01")
  sw.WriteLine("Export Surface Plane Angle Value=0.785398163397448")
  sw.WriteLine("; The output file format can be either BINARY or ASCII")
  sw.WriteLine("Output File Format=BINARY")
  sw.WriteLine("Enable Logging=On")
  sw.WriteLine("")
  sw.WriteLine("[Option Forms]")
  sw.WriteLine("Dll = STLOPT.DLL")
  sw.WriteLine("Import Entry Point = StlImptOptDialogOpen")
  sw.WriteLine("Export Entry Point = StlExptOptDialogOpen")
  sw.WriteLine("")
  sw.Close()
End Using

' Export the active document as STL using the previously stored options
Dim objDoc As SolidEdgePart.PartDocument = objApp.ActiveDocument
Dim strStlFile As String = objDoc.FullName.Substring(0, objDoc.FullName.Length - 3) & "stl"
objDoc.SaveCopyAs(strStlFile)

Re: Set SESTL.ini

This looks very good..

So if I use this code, the user wont get any right issues? For example if he doesnt have rights to access "SESTL.ini"?

 

Do you have this code in c++? Since I am badly experienced in vb!

 

Thank you very much!

Re: Set SESTL.ini

[ Edited ]

Hello,

 

when using the option dialog while saving as STL and due to user rights Solid Edge can't update the sestl.ini file in the Program folder of Solid Edge, a sestl.ini file will be created/modified in the user's profile folder, which then will be used by any SaveAs STL action.

 

I.e. for a user with user name Wku:

 

C:\Users\Wku\AppData\Roaming\Unigraphics Solutions\Solid Edge\Version 107\sestl.ini

 

So copying or creating a well prepared sestl.ini file into the user's profile will solve your problem of known parameters when using your Add-In to create a STL file.

 

Kind regards,
Wolfgang Kunert - www.wksyspro.de
Solution
Solution
Accepted by topic author bschla
‎09-11-2015 11:33 AM

Re: Set SESTL.ini

Independend of any access permissions of the SE Program folder, SE will always look first into the user profile folder for an option file, if it cannot find any, it will use the one in the Program folder. That's why you saw your ini file in the Program folder with the Inch option, while your current options were stored and used in the profile folder.

Here is he C++ code to export to STL:

HRESULT RunMacro(ApplicationPtr pSEApp, CSEMacroDlg *pDlg)
{
  HRESULT hr = NOERROR;

  try
  {
    //-----------------------------------------------------------------
    // TODO: Add your macro code here
    //-----------------------------------------------------------------
    // Get the users profile path
    CString strIniFile;
    PWSTR szRoamingPath = NULL;
    if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, NULL, &szRoamingPath)))
    {
      strIniFile.SetString(CW2A(szRoamingPath));
      CoTaskMemFree(szRoamingPath);
    }
    if (strIniFile.IsEmpty()) return E_FAIL;

    // Create a new SESTL.ini file with the desired units and tolerance values
    CString strVersion = pSEApp->GetVersion();
    strIniFile.AppendFormat("\\Unigraphics Solutions\\Solid Edge\\Version %s\\SESTL.ini", strVersion.Left(strVersion.Find('.')));
    FILE *fp = NULL;
    if (fopen_s(&fp, strIniFile, "w") != 0 || fp == NULL) return E_FAIL;
    fprintf(fp, "[Options]\n");
    fprintf(fp, "Memory Needed Per Native Element = 100000\n");
    fprintf(fp, "Memory Needed Per Foreign Element = 10000\n");
    fprintf(fp, "\n");
    fprintf(fp, ";Import Units Values can be Inch, Millimeter, or Meter\n");
    fprintf(fp, "Import Units=Millimeter\n");
    fprintf(fp, "Import Make Base Feature=On\n");
    fprintf(fp, "\n");
    fprintf(fp, ";Export Units Values can be Inch or Millimeter\n");
    fprintf(fp, "Export Units=Millimeter\n");
    fprintf(fp, "; The decimal delimiter for the tolerance and angle values MUST be a '.'\n");
    fprintf(fp, "Export Tolerance Value=0.01\n");
    fprintf(fp, "Export Surface Plane Angle Value=0.785398163397448\n");
    fprintf(fp, "; The output file format can be either BINARY or ASCII\n");
    fprintf(fp, "Output File Format=BINARY\n");
    fprintf(fp, "Enable Logging=Off\n");
    fprintf(fp, "\n");
    fprintf(fp, "[Option Forms]\n");
    fprintf(fp, "Dll = STLOPT.DLL\n");
    fprintf(fp, "Import Entry Point = StlImptOptDialogOpen\n");
    fprintf(fp, "Export Entry Point = StlExptOptDialogOpen\n");
    fprintf(fp, "\n");
    fclose(fp);

    PartDocumentPtr pDoc = pSEApp->GetActiveDocument();
    CString strStlFile = pDoc->GetFullName();
    strStlFile = strStlFile.Left(strStlFile.GetLength()-3);
    strStlFile.Append("stl");
    pDoc->SaveCopyAs(_bstr_t(strStlFile));
  }
  catch (_com_error &e)
  {
    CString msg;
    msg.Format("COM ERROR in %s (line %d)\n\n==> %s (%08x)", __FUNCTION__, __LINE__, e.ErrorMessage(), e.Error());
    AfxMessageBox(msg, MB_ICONERROR|MB_OK);
  }
  catch (...)
  {
    AfxMessageBox("ERROR: unexpected exception caught!", MB_ICONERROR|MB_OK);
  }   

  return hr;
}

Re: Set SESTL.ini

Thank you very much, this solved my problem! One last question: is the SESTL.ini per default after installation of solidedge in the Appdata/roaming... folder or does SE at some point create this folder after a specifi userevent?

Re: Set SESTL.ini

As i wrote above it happens as soon as the option dialog is used while exporting interactively to STL.

Kind regards,
Wolfgang Kunert - www.wksyspro.de