DesignVar for STL file paths

Hello,

I am trying to batch simulate using Python and I have encountered an error which I cannot find how to fix.

One of the things I am supposed to change when simulating is the STLs. So for every simulation I should input an STL file, whose position/rotation I have slightly modified using Python.

Now my problem is that when I try to declare it as a DesignVar it has the following error:

My code is as follows:

 AnyString file1 = DesignVar("./STL/file1.stl");

I understand what the error is saying, but I am not sure why wouldn't it take the variable into consideration if I use the DesignVar and also add an input to it? Because I have other variables on which I used the DesignVar, but they show no errors. The variables were also arrays and matrices so maybe that is one of the reasons it does not work?

Is there a way to make this work?

Any help is appreciated!

Hi Diana,

You can load different STLs to your model, but this is done different. Once the model is loaded and memory is allocated for all the STL structures - you cannot change the filename. But you can make a preprocessor statement: #define MYSTLFILE './STL/file1.stl' in the beginning of the model (order is important), which can then be changed on loading, but not once it is loaded.

If you use AnyPyTools - it can be possible to load models with a selected filename - check this:
https://anybody-research-group.github.io/anypytools-docs/Tutorial/02_Generating_macros.html

I hope this helps.

Kind regards,
Pavel

1 Like

Hi Pavel,

Yes, that was what I was looking for. I thought I could change the model after loading.

I will check it out, thanks!

Best,
Diana

This topic was automatically closed 125 days after the last reply. New replies are no longer allowed.