.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Solid3d.StlOut with a better quality?

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
stefan.hofer
533 Views, 7 Replies

Solid3d.StlOut with a better quality?

I had a script that eported my models to stl-files.

thisDrawing.SendCommand("STLOUT" +
    " " +
    "g" +
    " " +
    group.Name +
    Environment.NewLine +
    " " +
    " " +
    completeFilename +
    Environment.NewLine);

And i used the FACETRES variable to change the model quality.

acApp.SetSystemVariable("FACETRES", 8);

 

First problem is: Since Acad2021 it does no longer change the variable via script. Other variables like FILEDIA are still working.

 

Second: I found a better way to export the models. But this example completly ignore the FACETRES value and and export super lowpoly only.

Solid3d sol = (Solid3d)tr.GetObject(myId, OpenMode.ForRead);
sol.StlOut(Path.Combine(targetDirectory, newFileName + ".stl"), true); //ignore facetres settings

 

It's possible to get a higher quality with that solid3d.stlout command?

7 REPLIES 7
Message 2 of 8


@stefan.hofer wrote:

...First problem is: Since Acad2021 it does no longer change the variable via script. Other variables like FILEDIA are still working.

Are you sure???

 


@stefan.hofer wrote:

Second: I found a better way to export the models. But this example completly ignore the FACETRES value and and export super lowpoly only.

Solid3d sol = (Solid3d)tr.GetObject(myId, OpenMode.ForRead);
sol.StlOut(Path.Combine(targetDirectory, newFileName + ".stl"), true); //ignore facetres settings

 

It's possible to get a higher quality with that solid3d.stlout command?


You can try to P/Invoke AcDb3dSolid::stlOut(const ACHAR* fileName,
Adesk::Boolean asciiFormat, double maxSurfaceDeviation = 0.0 /*use default*/) const;

(available since AutoCAD 2015)

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 3 of 8

-> Are you sure??? yes i am.

double originalfacetres = System.Convert.ToDouble(acApp.GetSystemVariable("FACETRES"));
ed.WriteMessage("FACETRES original value: " + originalfacetres.ToString() + "\n"); //result is 1

acApp.SetSystemVariable("FACETRES", 8);
double newfacetres = System.Convert.ToDouble(acApp.GetSystemVariable("FACETRES"));
ed.WriteMessage("FACETRES new value: " + newfacetres.ToString() + "\n"); //result is (still) 1

 

-> AcDb3dSolid

that's objectARX isn't it?

if this is the only way to do this i just give up at this point and live with this result.

 

Message 4 of 8
stefan.hofer
in reply to: stefan.hofer

Well i found a solution for the FACETRES problem

//Does not work
Autodesk.AutoCAD.ApplicationServices.Core.Application.SetSystemVariable("FACETRES", 8);

//This one work...
AcadDocument myDrawing = (AcadDocument)Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument.GetAcadDocument();
myDrawing.SetVariable("FACETRES", 8);
Message 5 of 8
stefan.hofer
in reply to: stefan.hofer

okay this is a bit embarrassing but my first post was not entirely correct...

 

Solid3d.StlOut does not ignore the FACETRES value. I had a different problem.

The FACETRES variable is per drawing and not global.

(I create a new drawing for the export and had to change the variable in this new document and everything looks good now)

Message 6 of 8

 

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;

// This line is not mandatory, but improves loading performances
[assembly: CommandClass(typeof(SetFacetRes.MyCommands))]

namespace SetFacetRes
{
  public class MyCommands
  {
    [CommandMethod("SetFacetRes")]
    public void MyCommand()
    {
      Document doc = Application.DocumentManager.MdiActiveDocument;
      Editor ed = doc.Editor;
      double fasetRes = (double) Application.GetSystemVariable("FACETRES");
      ed.WriteMessage("\nFacetRes={0}", fasetRes);
      Application.SetSystemVariable("FACETRES", 8);
      fasetRes = (double)Application.GetSystemVariable("FACETRES");
      ed.WriteMessage("\nFacetRes={0}", fasetRes);
    }
  }
}

 

изображение.png

 

What wrong? AutoCAD 2021.1.1

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 7 of 8

Other way for setting FACETRES is using Database.Facetres property.

 
 

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 8 of 8
stefan.hofer
in reply to: stefan.hofer

-> Other way for setting FACETRES is using Database.Facetres property.

 

don't forget the DocumentLock this way 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report