parameters for scene.mouse.pick()

16 views
Skip to first unread message

EDUCATIA SUPERLATIV

unread,
Nov 19, 2025, 6:42:47 AMNov 19
to VPython-users
Hi,

I want to know all parameters for scene.mouse.pick()?

How can I obtain the nameX of the object?

Example:

nameX = box({...})
let hit = scene.mouse.pick()

I want to obtain string = ”that NameX” after pick on object?
The ”hit.constructor.name” show the type of the object!!!!

Best regards,
Ciprian

John

unread,
Nov 19, 2025, 11:05:30 AMNov 19
to VPython-users
Have a look at this modified example picking program.

https://glowscript.org/#/user/johncoady/folder/My_Programs/program/PickName

If you pick an object it will print the name of the object that I assigned it when it was created. For instance I added the name 'green box' to the box object when I created it.

box(pos=vector(1,-1,0), color=color.green, name='green box')

and I print the name in the getevent() routine

        print("Pick Name : ",lasthit.name)


Michael Burns-Kaurin

unread,
Nov 19, 2025, 11:58:12 AMNov 19
to vpytho...@googlegroups.com
Simpler example https://glowscript.org/#/user/johncoady/folder/My_Programs/program/PickName

Web VPython 3.2

cube = box()
cube.name = "cube"
t = 0
dt = 0.1
while t <= 20:
    rate(10)
    now = scene.mouse
    if not now.pick == False:
        print(now.pick.name)
    else:
        print("nada")
    t+= dt

--
You received this message because you are subscribed to the Google Groups "VPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vpython-user...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/vpython-users/aca533e9-5f6e-4595-a41a-e9e2f03d5cf9n%40googlegroups.com.

EDUCATIA SUPERLATIV

unread,
Nov 24, 2025, 5:30:15 AM (11 days ago) Nov 24
to VPython-users
Many thanks,
I will test it!!!
Best regards,
Ciprian

EDUCATIA SUPERLATIV

unread,
Nov 24, 2025, 5:57:46 AM (11 days ago) Nov 24
to VPython-users
I work with VPython in Html!
I tested like this:
let Hbox = box( {pos:Hpoz, size:vec(dX, dY, dZ), color:cList[colID]}, name = NameX )  //OK
print("Current Name : ", NameX)   // OK

But when I click on the object it say ”Pick Name :  undefined”!

Best regards,
Ciprian

EDUCATIA SUPERLATIV

unread,
Nov 24, 2025, 6:19:54 AM (11 days ago) Nov 24
to VPython-users
Another observation!
Another difference was not defined variables like global in HTML!
”//global lasthit, lastpick, lastcolor”
Doesn't work!
Is it possible to define in HTML VPython global variables?

Reply all
Reply to author
Forward
0 new messages