how can i draw

Typically: "How do I... ", "How can I... " questions
qwerty
Posts: 12
Joined: 01 Jun 2023, 13:29

how can i draw

Post by qwerty »

Hello,

I have a CSV file with force data and I want to be able to draw a circle on the ground that will be "at the foot" of an object and I want the circle to grow and decrease according to the value of the force. Is it possible to do that ?
I'm using the python API.

Thanks in advance

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: how can i draw

Post by fferri »

Yes, with sim.addDrawingObject and sim.addDrawingObjectItem

qwerty
Posts: 12
Joined: 01 Jun 2023, 13:29

Re: how can i draw

Post by qwerty »

thank you for your reply.
Is it possible to have an example ?

qwerty
Posts: 12
Joined: 01 Jun 2023, 13:29

Re: how can i draw

Post by qwerty »

Every time I try to put this function in my code I get this error :

AttributeError: module 'sim' has no attribute 'addDrawingObject'

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: how can i draw

Post by fferri »

It is highly recommended to use the ZeroMQ remote API, since it is much easier and flexible. Additionally, you'll have access to many more API functions, than with the legacy remote API.

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: how can i draw

Post by fferri »

For what you want to draw, you can use sim.drawing_discpts (to draw discs) combined with sim.drawing_itemsizes which takes one additional number (in sim.addDrawingObjectItem) to specify the item size:

Code: Select all

dwo=sim.addDrawingObject(sim.drawing_discpts|sim.drawing_itemsizes,0.1,0,-1,1000,{1,0,0})
--                            pos:          quat:       size:
sim.addDrawingObjectItem(dwo,{0.5,  0,0,    0,0,0,1,    0.2})
sim.addDrawingObjectItem(dwo,{  0,0.5,0,    0,0,0,1,    0.1})
sim.addDrawingObjectItem(dwo,{0.5,0.5,0,    0,0,0,1,    0.05})

qwerty
Posts: 12
Joined: 01 Jun 2023, 13:29

Re: how can i draw

Post by qwerty »

Thank you for your help.
I have another question.
With this API can I still use my previous codes made with the other API or do I have to readapt my code?
Thank you in advance for your answer

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: how can i draw

Post by fferri »

The ZMQ Remote API is a 1:1 equivalent of the (lua) Regular API.
If you used the Regular API (e.g. in model scripts), it works in the same way.
If you used the legacy Remote API you might need to make minor adjustments.

qwerty
Posts: 12
Joined: 01 Jun 2023, 13:29

Re: how can i draw

Post by qwerty »

very good and I have another question.
Can I attach this obet create to another object for example I would like the circle to be created at the foot of a cane ?

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: how can i draw

Post by fferri »

Yes (by passing the foot handle to the parentObjectHandle param).

Post Reply