POV-Ray : Newsgroups : povray.general : Convert string identifier to object name Server Time
4 Nov 2024 23:17:03 EST (-0500)
  Convert string identifier to object name (Message 1 to 10 of 12)  
Goto Latest 10 Messages Next 2 Messages >>>
From: Thomas de Groot
Subject: Convert string identifier to object name
Date: 2 Nov 2009 04:38:52
Message: <4aeea8ac$1@news.povray.org>
This is a bit similar to SharkD's question above, but I wonder if it is 
possible.

What I want to do is the following:

#local PoserName = "Beggar_";
#include concat(PoserName, "POV_geom.inc")
#local ObjName = object {PoserName}

The first two line of code work correctly, but the third one generates a 
parse error of course, as a string identifier instead of an object is found. 
How can I make this work?

-- 
All the best,

Thomas


Post a reply to this message

From: Stephen
Subject: Re: Convert string identifier to object name
Date: 2 Nov 2009 05:25:38
Message: <4aeeb3a2$1@news.povray.org>
Thomas de Groot wrote:
> This is a bit similar to SharkD's question above, but I wonder if it is 
> possible.
> 
> What I want to do is the following:
> 
> #local PoserName = "Beggar_";
> #include concat(PoserName, "POV_geom.inc")
> #local ObjName = object {PoserName}
> 
> The first two line of code work correctly, but the third one generates a 
> parse error of course, as a string identifier instead of an object is found. 
> How can I make this work?
> 

similar problem with wanting to include a frame number in the name of 
the object (in PovRay) until I saw that you can define in PoseRay what 
you want to name the object.

-- 

Best Regards,
	Stephen


Post a reply to this message

From: Chris B
Subject: Re: Convert string identifier to object name
Date: 2 Nov 2009 06:26:20
Message: <4aeec1dc@news.povray.org>
"Thomas de Groot" <tDOTdegroot@interDOTnlANOTHERDOTnet> wrote in message 
news:4aeea8ac$1@news.povray.org...
> This is a bit similar to SharkD's question above, but I wonder if it is 
> possible.
>
> What I want to do is the following:
>
> #local PoserName = "Beggar_";
> #include concat(PoserName, "POV_geom.inc")
> #local ObjName = object {PoserName}
>
> The first two line of code work correctly, but the third one generates a 
> parse error of course, as a string identifier instead of an object is 
> found. How can I make this work?
>
> -- 
> All the best,
>
> Thomas
>

I assume that an object called 'Beggar_' is declared within the include 
file?
If so you could use the Parse_String(String) macro. This macro takes a 
string, writes it to a file, and then includes that file, effectively 
evaluating the string, so:

#include "strings.inc"
Parse_String(concat("object {",PoserName,"}"))

should do it. Warning. I didn't test this for syntax errors.

Regards,
Chris B.


Post a reply to this message

From: Thomas de Groot
Subject: Re: Convert string identifier to object name
Date: 2 Nov 2009 07:20:09
Message: <4aeece79$1@news.povray.org>
"Stephen" <mca### [at] aolDOTcom> schreef in bericht 
news:4aeeb3a2$1@news.povray.org...

> problem with wanting to include a frame number in the name of the object 
> (in PovRay) until I saw that you can define in PoseRay what you want to 
> name the object.

Yes, I know this posibility, but that is not my problem. I try to simplify a 
POV-Ray test scene for Poser figures that I use regularly, where I simply 
have to give the generic name of the figure only once.

Thomas


Post a reply to this message

From: Thomas de Groot
Subject: Re: Convert string identifier to object name
Date: 2 Nov 2009 07:34:50
Message: <4aeed1ea@news.povray.org>
"Chris B" <nom### [at] nomailcom> schreef in bericht 
news:4aeec1dc@news.povray.org...
> I assume that an object called 'Beggar_' is declared within the include 
> file?

Yes indeed.

> If so you could use the Parse_String(String) macro. This macro takes a 
> string, writes it to a file, and then includes that file, effectively 
> evaluating the string, so:
>
> #include "strings.inc"
> Parse_String(concat("object {",PoserName,"}"))
>

Perfect Chris! It works. I just  changed my code line to:

#local ObjName = Parse_String(concat("object {",PoserName,"}"))

and used that for further work in the scene.

Thomas

PS I shall have to look into strings.inc to discover what more is hidden 
there :-)  Fact is that I do not know *everything* that POV-Ray offers....


Post a reply to this message

From: Stephen
Subject: Re: Convert string identifier to object name
Date: 2 Nov 2009 07:47:29
Message: <4aeed4e1$1@news.povray.org>
Thomas de Groot wrote:
> "Stephen" <mca### [at] aolDOTcom> schreef in bericht 
> news:4aeeb3a2$1@news.povray.org...

>> problem with wanting to include a frame number in the name of the object 
>> (in PovRay) until I saw that you can define in PoseRay what you want to 
>> name the object.
> 
> Yes, I know this posibility, but that is not my problem. I try to simplify a 
> POV-Ray test scene for Poser figures that I use regularly, where I simply 
> have to give the generic name of the figure only once.
> 
> Thomas
> 
> 




-- 

Best Regards,
	Stephen


Post a reply to this message

From: clipka
Subject: Re: Convert string identifier to object name
Date: 2 Nov 2009 08:15:36
Message: <4aeedb78$1@news.povray.org>
Thomas de Groot schrieb:

> Perfect Chris! It works. I just  changed my code line to:
> 
> #local ObjName = Parse_String(concat("object {",PoserName,"}"))
> 
> and used that for further work in the scene.
> 
> Thomas
> 
> PS I shall have to look into strings.inc to discover what more is hidden 
> there :-)  Fact is that I do not know *everything* that POV-Ray offers....

Fun facts to know:

The Parse_String macro actually "inlines" the string by writing it to a 
temporary file, which it then includes.


Post a reply to this message

From: Chris B
Subject: Re: Convert string identifier to object name
Date: 2 Nov 2009 08:21:53
Message: <4aeedcf1$1@news.povray.org>
"Thomas de Groot" <tDOTdegroot@interDOTnlANOTHERDOTnet> wrote in message 
news:4aeed1ea@news.povray.org...
>
> PS I shall have to look into strings.inc to discover what more is hidden 
> there :-)  Fact is that I do not know *everything* that POV-Ray offers....
>

Nor do I.  :o)
That's one great thing about using such a mature application. It's got 
depth. Lots of handy tricks and features just waiting to be explored.

Regards,
ChrisB.


Post a reply to this message

From: Thomas de Groot
Subject: Re: Convert string identifier to object name
Date: 2 Nov 2009 10:34:18
Message: <4aeefbfa@news.povray.org>
"Chris B" <nom### [at] nomailcom> schreef in bericht 
news:4aeedcf1$1@news.povray.org...
>
> Nor do I.  :o)
> That's one great thing about using such a mature application. It's got 
> depth. Lots of handy tricks and features just waiting to be explored.
>

Which makes one marvel (and slaver) at all those hidden goodies :-)

Thomas


Post a reply to this message

From: Thomas de Groot
Subject: Re: Convert string identifier to object name
Date: 2 Nov 2009 10:34:47
Message: <4aeefc17$1@news.povray.org>
"clipka" <ano### [at] anonymousorg> schreef in bericht 
news:4aeedb78$1@news.povray.org...
> Fun facts to know:
>
> The Parse_String macro actually "inlines" the string by writing it to a 
> temporary file, which it then includes.

Neat.

Thomas


Post a reply to this message

Goto Latest 10 Messages Next 2 Messages >>>

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