Physion

  • Increase font size
  • Default font size
  • Decrease font size
Welcome, Guest
Username Password: Remember me

Help with coding
(1 viewing) (1) Guest

TOPIC: Help with coding

Help with coding 6 years, 4 months ago #210

  • Nait
  • OFFLINE
  • Senior Boarder
  • Posts: 60
Well, as I see, there is no specialized topic for asking questions.
I think, Admin won't object, if I make it here. And I also will try to help you, as I'm little expired in this subject.

Re: Help with coding 6 years, 4 months ago #220

  • Dimitris
  • OFFLINE
  • Administrator
  • Posts: 218
No objection at all, I'll be happy if you could provide some coding help to anyone who needs it.

And yes maybe I should create a separate forum section for scripting.

Thanx

EDIT: Created "Scripting" section
Last Edit: 6 years, 4 months ago by Dimitris.

Re: Help with coding 6 years, 4 months ago #226

  • Nait
  • OFFLINE
  • Senior Boarder
  • Posts: 60
Well, what is about reading properties of selected items?

Re: Help with coding 6 years, 4 months ago #232

  • Dimitris
  • OFFLINE
  • Administrator
  • Posts: 218
Hmmm... I don't really understand your question Nait.

Could you elaborate a little bit on that?

Re: Help with coding 6 years, 4 months ago #236

  • Nait
  • OFFLINE
  • Senior Boarder
  • Posts: 60
I'm making toolbar for selection and I want to make a button "Follow with camera", so I need to read Name of selected item.
graphicsView.BodyWithCamera=world.selectedItems.Name

Re: Help with coding 6 years, 4 months ago #241

  • Dimitris
  • OFFLINE
  • Administrator
  • Posts: 218
You could use something like that to get the current selection set

 
function currentSelectionSet()
{
var graphicsItems = graphicsView.scene().selectedItems();
var physicsItems = new Array();
 
var index = 0;
for(var i=0; i<graphicsItems.length; i++)
{
var graphicsItem = graphicsItems[i];
 
var physicsItem = world.physicsItemFromGraphicsItem(graphicsItem);
if(physicsItem)
physicsItems[index++] = physicsItem;
}
 
return physicsItems;
}
 


Hope it helps
Last Edit: 6 years, 4 months ago by Dimitris.
Moderators: Lynxx, Glenn555
Time to create page: 0.19 seconds