POV-Ray : Newsgroups : povray.newusers : object name problem Server Time
31 Oct 2024 20:02:26 EDT (-0400)
  object name problem (Message 1 to 4 of 4)  
From: kurtz le pirate
Subject: object name problem
Date: 9 May 2013 09:00:20
Message: <kurtzlepirate-3A0A2B.15002009052013@news.povray.org>
hello,

I have a macro that generates a mesh object in a "inc" file.

I declare a variables :
  #declare objectName = "TheBrick";


My macro write this name in the inc file with this code :

   #write(OUTFILE,"#declare ",objectName," = mesh {\n")

which generates :

#declare TheBrick = mesh {
  triangle {<-4.25,2.25,-3.25>,<-3.57,2.33,-3.33>,<-4.33,2.33,-2.57>}
  triangle {<-4.33,2.33,-2.57>,<-3.57,2.33,-3.33>,<-3.57,2.52,-2.57>}
  triangle {<-3.57,2.33,-3.33>,<-3.15,2.33,-3.33>,<-3.57,2.52,-2.57>}
  ...
  ...
  }


Now, in the main script if i write :

#include fileName
object {
  objectName
  pigment { color White }
  finish { ambient 0 }
  }


I get this parse error :

  Expected 'object', string identifier found instead.

Seems consistent, but then how can I use this variable to draw object ?

 
Of corse, if i write :
object {
  TheBrick
  pigment { color White }
  finish { ambient 0 }
  }

everything is good. 



-- 
klp


Post a reply to this message

From: Trevor G Quayle
Subject: Re: object name problem
Date: 9 May 2013 11:10:00
Message: <web.518bbc059f3aa2d281c811d20@news.povray.org>
kurtz le pirate <kur### [at] yahoofr> wrote:
> hello,
>
> I have a macro that generates a mesh object in a "inc" file.
>
> I declare a variables :
>   #declare objectName = "TheBrick";
>
>
> My macro write this name in the inc file with this code :
>
>    #write(OUTFILE,"#declare ",objectName," = mesh {\n")
>
> which generates :
>
> #declare TheBrick = mesh {
>   triangle {<-4.25,2.25,-3.25>,<-3.57,2.33,-3.33>,<-4.33,2.33,-2.57>}
>   triangle {<-4.33,2.33,-2.57>,<-3.57,2.33,-3.33>,<-3.57,2.52,-2.57>}
>   triangle {<-3.57,2.33,-3.33>,<-3.15,2.33,-3.33>,<-3.57,2.52,-2.57>}
>   ...
>   ...
>   }
>
>
> Now, in the main script if i write :
>
> #include fileName
> object {
>   objectName
>   pigment { color White }
>   finish { ambient 0 }
>   }
>
>
> I get this parse error :
>
>   Expected 'object', string identifier found instead.
>
> Seems consistent, but then how can I use this variable to draw object ?
>
>
> Of corse, if i write :
> object {
>   TheBrick
>   pigment { color White }
>   finish { ambient 0 }
>   }
>
> everything is good.
>
>
>
> --
> klp

You are trying to use 'objectname' as an indirect reference which can't work in
POV.  At runtime, it does not substitute "TheBrick" text in place of the
"objectname" text, instead it simply sees 'ojectname' as a string and not an
object, hence the error.

-tgq


Post a reply to this message

From: clipka
Subject: Re: object name problem
Date: 9 May 2013 20:12:16
Message: <518c3b60$1@news.povray.org>
Am 09.05.2013 15:00, schrieb kurtz le pirate:

> I declare a variables :
>    #declare objectName = "TheBrick";
>
>
> My macro write this name in the inc file with this code :
>
>     #write(OUTFILE,"#declare ",objectName," = mesh {\n")
>
> which generates :
>
> #declare TheBrick = mesh {
>    triangle {<-4.25,2.25,-3.25>,<-3.57,2.33,-3.33>,<-4.33,2.33,-2.57>}
>    triangle {<-4.33,2.33,-2.57>,<-3.57,2.33,-3.33>,<-3.57,2.52,-2.57>}
>    triangle {<-3.57,2.33,-3.33>,<-3.15,2.33,-3.33>,<-3.57,2.52,-2.57>}
>    ...
>    ...
>    }
>
>
> Now, in the main script if i write :
>
> #include fileName
> object {
>    objectName
>    pigment { color White }
>    finish { ambient 0 }
>    }
>
>
> I get this parse error :
>
>    Expected 'object', string identifier found instead.
>
> Seems consistent, but then how can I use this variable to draw object ?

Try the "Parse_Strings" macro:

   #include "strings.inc"
   ...
   object {
     Parse_String(objectName)
     ...
   }


Post a reply to this message

From: kurtz le pirate
Subject: Re: object name problem
Date: 11 May 2013 03:36:59
Message: <kurtzlepirate-08FB05.09365811052013@news.povray.org>
In article <518c3b60$1@news.povray.org>,
 clipka <ano### [at] anonymousorg> wrote:

> Try the "Parse_Strings" macro:
> 
>    #include "strings.inc"
>    ...
>    object {
>      Parse_String(objectName)
>      ...
>    }


i try... thanks

-- 
klp


Post a reply to this message

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