POV-Ray : Newsgroups : povray.general : printing object's identifier Server Time
25 Dec 2024 20:23:11 EST (-0500)
  printing object's identifier (Message 1 to 10 of 20)  
Goto Latest 10 Messages Next 10 Messages >>>
From: jr
Subject: printing object's identifier
Date: 16 Mar 2016 18:35:38
Message: <56e9dfba$1@news.povray.org>
hi,

I'm trying to print, from a macro, the declared name of an object passed
to it, ie.

#declare Tobj = torus { ... };

object { Tobj }

mymacro(Tobj)

and in the macro (where the parameter is ObjId)

#debug concat("object's name:", ObjId)

that doesn't work, POV complains "expected string, oid found instead",
so is there a way to get the name string ('Tobj') from the ObjId?

thank you.

jr.


Post a reply to this message

From: clipka
Subject: Re: printing object's identifier
Date: 16 Mar 2016 19:50:42
Message: <56e9f152$1@news.povray.org>
Am 16.03.2016 um 23:35 schrieb jr:
> hi,
> 
> I'm trying to print, from a macro, the declared name of an object passed
> to it, ie.
> 
> #declare Tobj = torus { ... };
> 
> object { Tobj }
> 
> mymacro(Tobj)
> 
> and in the macro (where the parameter is ObjId)
> 
> #debug concat("object's name:", ObjId)
> 
> that doesn't work, POV complains "expected string, oid found instead",
> so is there a way to get the name string ('Tobj') from the ObjId?

This question has been asked before.

Short answer: It's not possible.

Almost equally short answer: It doesn't make sense. If it would work,
POV-Ray would print "ObjId" instead of "Tobj", because the macro has no
knowledge of any prior name of the object.

What you /could/ do is approach it the other way round, converting a
string to an identifier:

#declare Tobj = torus { ... };
object { Tobj }
mymacro("Tobj")

and in mymacro use the Parse_String macro (from string.inc... or is it
strings.inc? I never can remember) to convert the string to an identifier.
Note however that in this case you must somehow make sure that you don't
pass the name of an identifier that is also declared locally in the macro.


Post a reply to this message

From: jr
Subject: Re: printing object's identifier
Date: 16 Mar 2016 20:32:03
Message: <56e9fb03$1@news.povray.org>
hi clipka,

On 16/03/2016 23:50, clipka wrote:

thanks for swift response.  this approach led to a different problem
(see below).  the macro is stored in its own file and meant to be
general purpose (to trace the outline of whichever object was passed via
ObjId), and I need both the object's name (for feedback and to populate
a field in the output), and the object to trace.  I'm now thinking,
given the below, it might be easier/better to supply both the name and
the identifier as separate arguments, do you concur?

jr.


#declare Tobj = torus { ... };
object { Tobj }
mymacro("Tobj")

#debug concat("id: ", ObjId)

Parse_String(ObjId)
#local bbox_min = min_extent(ObjId)

POV now fails on the min_extent since I'm passing it a string..


Post a reply to this message

From: dick balaska
Subject: Re: printing object's identifier
Date: 16 Mar 2016 21:07:48
Message: <56ea0364$1@news.povray.org>
Am 2016-03-16 20:31, also sprach jr:
>I'm now thinking,
> given the below, it might be easier/better to supply both the name and
> the identifier as separate arguments,

That's the way I do it.

C'est la vie.

-- 
dik


Post a reply to this message

From: clipka
Subject: Re: printing object's identifier
Date: 16 Mar 2016 21:42:09
Message: <56ea0b71$1@news.povray.org>
Am 17.03.2016 um 01:31 schrieb jr:
> hi clipka,
> 
> On 16/03/2016 23:50, clipka wrote:
> 
> thanks for swift response.  this approach led to a different problem
> (see below).  the macro is stored in its own file and meant to be
> general purpose (to trace the outline of whichever object was passed via
> ObjId), and I need both the object's name (for feedback and to populate
> a field in the output), and the object to trace.  I'm now thinking,
> given the below, it might be easier/better to supply both the name and
> the identifier as separate arguments, do you concur?
> 
> jr.
> 
> 
> #declare Tobj = torus { ... };
> object { Tobj }
> mymacro("Tobj")
> 
> #debug concat("id: ", ObjId)
> 
> Parse_String(ObjId)
> #local bbox_min = min_extent(ObjId)
> 
> POV now fails on the min_extent since I'm passing it a string..

You need to use

#local bbox_min = min_extent( Parse_String(ObjId) );

But yes, it would probably be easier to have two separate parameters,
one specifying the object and one specifying a string to use as a "name"
for that object.


Post a reply to this message

From: jr
Subject: Re: printing object's identifier
Date: 17 Mar 2016 09:37:23
Message: <56eab313$1@news.povray.org>
hi,

ok, separate arguments it is.  thank you clipka & Dick B.

On 17/03/2016 01:41, clipka wrote:
> You need to use
> #local bbox_min = min_extent( Parse_String(ObjId) );

thank you for showing the correct use.  fwiw I did grep for this macro
in all 3.7.0 (scene) files, it does not appear used anywhere.

jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: printing object's identifier
Date: 17 Mar 2016 10:30:01
Message: <web.56eabebf374275025e7df57c0@news.povray.org>
jr <cre### [at] gmailcom> wrote:

> thank you for showing the correct use.  fwiw I did grep for this macro
> in all 3.7.0 (scene) files, it does not appear used anywhere.
>
> jr.

Given just HOW MUCH stuff POV-Ray has jammed into it, that's not entirely
surprising.   Documenting features takes a lot more time and care (for me) than
coding a scene.

Perhaps if you could write up a small, commented SDL file that illustrates and
demonstrates this particular feature, then it would be available to anyone in
the future searching the newsgroups and wanting to know how to go about using
it.

"Many hands make light work", and all that   :)

Glad you're getting it to work out.


Post a reply to this message

From: jr
Subject: Re: printing object's identifier
Date: 18 Mar 2016 14:01:18
Message: <56ec426e$1@news.povray.org>
hi,

On 17/03/2016 14:27, Bald Eagle wrote:
>> thank you for showing the correct use.  fwiw I did grep for this macro
>> in all 3.7.0 (scene) files, it does not appear used anywhere.
>>
> 
> Given just HOW MUCH stuff POV-Ray has jammed into it, that's not entirely
> surprising.   Documenting features takes a lot more time and care (for me) than
> coding a scene.
> 
> Perhaps if you could write up a small, commented SDL file that illustrates and
> demonstrates this particular feature, then it would be available to anyone in
> the future searching the newsgroups and wanting to know how to go about using
> it.

man, talk about bein' put on the spot.  ;-)

I don't mind doing the 'legwork' (though, as a beginner, just how useful
such a sample scene would be is questionable), but have to confess that
I can not think of /any/ realistic use case for Parse_String(); lack of
use case may well be a contributing factor to the macro not being used
in the sample scenes.

I will put a simple, contrived scene file together, give me a few days
please, I'm in the middle of my own stuff right now.

> "Many hands make light work", and all that   :)

agree.

a fanciful thought on the subject: given the recent revolution in
self-publishing, perhaps, between the povray news group users, a wiki
could be nurtured to the point of producing/selling a print-on-demand
book on using/programming POV?  (I know I'd buy :-))

jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: printing object's identifier
Date: 18 Mar 2016 14:20:00
Message: <web.56ec4699374275025e7df57c0@news.povray.org>
jr <cre### [at] gmailcom> wrote:

> man, talk about bein' put on the spot.  ;-)

:D

> I don't mind doing the 'legwork' (though, as a beginner, just how useful
> such a sample scene would be is questionable), but have to confess that
> I can not think of /any/ realistic use case for Parse_String(); lack of
> use case may well be a contributing factor to the macro not being used
> in the sample scenes.
>
> I will put a simple, contrived scene file together, give me a few days
> please, I'm in the middle of my own stuff right now.

 It just needs to be a little working SDL blurb that can be used as or pasted
into a macro.   Though sometimes it can be surprising what some people can do
with a little feature once they start to contemplate what it might be used for.

It was simply a suggestion - please take your time and pardon my shameless and
opportunistic "tagging" of you.  ;)

I hope your project is working out well.  I wish you further luck and success.


Post a reply to this message

From: jr
Subject: Re: printing object's identifier
Date: 18 Mar 2016 21:38:06
Message: <56ecad7e@news.povray.org>
hi,

>> I will put a simple, contrived scene file together, give me a few days..

I'm sure you know how, (often) immediately writing something like "can
not think of /any/ realistic use case" an idea, from nowhere, lodges
itself in the brain, persistent, like an itch that must be scratched?
anyway, it happened and I had to get it of my system, the resulting file
is attached.

> It was simply a suggestion - please take your time and pardon my shameless and
> opportunistic "tagging" of you.  ;)

too late!  :-)

the .pov illustrates building object identifiers dynamically via cli.
the file is commented and works with version 3.7.0.  it does lack visual
pizzazz but I'm no artist anyway.  also, the newlines in the error
messages don't work on my machine.

regards, jr.


Post a reply to this message


Attachments:
Download 'utf-8' (2 KB)

Goto Latest 10 Messages Next 10 Messages >>>

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