POV-Ray : Newsgroups : povray.newusers : Loops and strings Server Time
27 Dec 2024 10:58:02 EST (-0500)
  Loops and strings (Message 1 to 4 of 4)  
From: Dedus
Subject: Loops and strings
Date: 21 Mar 2016 16:25:00
Message: <web.56f05768dab79262d18e5a860@news.povray.org>
Hello,

I have got a question about using strings and loops in povray.

I have got about 60 objects with the same attributes but they all have got
different meshes that come from STL-files.

Like this:

object{ somemesh_xx
  ...
  ...
  ...
}

"somemesh_xx" is a string and I want to generate 60 different objects from 60
different STL-files by using a loop with the variable "xx".
So I would like avoid writing somemesh_01 , somemesh_02 , ... , somemesh_60
and to be able to change the attribute of all by only changing one variable.


I would be glad if you could help me.


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Loops and strings
Date: 21 Mar 2016 16:37:04
Message: <56f05b70$1@news.povray.org>
On 21.03.2016 21:19, Dedus wrote:

> "somemesh_xx" is a string and I want to generate 60 different objects from 60
> different STL-files by using a loop with the variable "xx".
> So I would like avoid writing somemesh_01 , somemesh_02 , ... , somemesh_60
> and to be able to change the attribute of all by only changing one variable.

there is a Parse_String macro in strings.inc that should work for you.


Post a reply to this message

From: Stephen
Subject: Re: Loops and strings
Date: 21 Mar 2016 17:36:03
Message: <56f06943$1@news.povray.org>
On 3/21/2016 8:19 PM, Dedus wrote:
> "somemesh_xx" is a string and I want to generate 60 different objects from 60
> different STL-files by using a loop with the variable "xx".
> So I would like avoid writing somemesh_01 , somemesh_02 , ... , somemesh_60
> and to be able to change the attribute of all by only changing one variable.

You might want to think of using concat in a loop. Below is code to 
include a file "Chain02G2Y_XX.pov" where XX depends on the frame number.


#include 
concat("f:\\Graphics\\Data\\Chain02G2Y_",str(mod(frame_number,89),-4,0),".pov")



-- 

Regards
     Stephen


Post a reply to this message

From: Alain
Subject: Re: Loops and strings
Date: 21 Mar 2016 18:54:40
Message: <56f07bb0@news.povray.org>

> Hello,
>
> I have got a question about using strings and loops in povray.
>
> I have got about 60 objects with the same attributes but they all have got
> different meshes that come from STL-files.
>
> Like this:
>
> object{ somemesh_xx
>    ...
>    ...
>    ...
> }
>
> "somemesh_xx" is a string and I want to generate 60 different objects from 60
> different STL-files by using a loop with the variable "xx".
> So I would like avoid writing somemesh_01 , somemesh_02 , ... , somemesh_60
> and to be able to change the attribute of all by only changing one variable.
>
>
> I would be glad if you could help me.
>
>
>
>

Why not use an array of meshes?
 From the documentation, ANY item that can be declared as an identifier 
can be declared in an array.

As you can do this:
#declare MyMesh = mesh{....}

you can do:
#declare MyMeshArray = array[60]
Then, in a loop, read your STL files for the various mesh elements.

Instead of having somemesh_01, you have somemesh[1].


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.