Hello Ventuzians!
THE FORUMS ARE CLOSED!

Please join our discord server HERE!! << click me :D

We are shutting our Ventuz Forum, but don't worry, it will all be archived for you to search in if you have a query. From now on, please add all your comments, questions or observations into our Discord Server

Thanks for the great time - see you on discord!!
Dee, Karol, Daniel and the whoooole Product and Support team!

chagne project data from c# script

Q and A about functionality and how to solve a special task for your application.

Moderator: Support

Post Reply
User avatar
dekacko
Posts: 3
Joined: 07 Mar 2016, 11:50

chagne project data from c# script

Post by dekacko » 22 Aug 2017, 16:27

hi, I would like to acces (change) project data from c# script node, accessing scene data via this.scene is quite easy. I understand it is possible by using remoting4 in script. but i am not very skilled in c# and am not able to figure this out. could you somebody help me pls.

thanks a lot

stephen
Posts: 74
Joined: 06 Aug 2013, 14:11

Re: chagne project data from c# script

Post by stephen » 23 Aug 2017, 09:24

Hi dekacko,

there are two steps in order to accomplish that.

1. Create and initiate a cluster object of your local machine.

Code: Select all

using Ventuz.Remoting4;
using System.Net;

//...

private Cluster cluster = null;

//this can be called e.g. by a Method on the Script Node
private void ConnectToLocalMachine()
{
 IPAddress ipAdr = IPAddress.Parse("127.0.0.1");
 this.cluster = new Cluster { Name = "Local" };
 this.cluster.AddMachine(new IPEndPoint(ipAdr, Cluster.DEFAULT_PORT));
 this.cluster.Start();
}
2. Now you can access the loaded project's data model somewhere in your code using a String for the full item's Address Path and an object of the type of the data channel as the first two arguments of the Cluster.ProjectDataItem Method.

Code: Select all

if(this.cluster != null)
{
 try
 {
  this.cluster.ProjectDataItem(".ProjectDataFolder.ItemName", 23, null, null);
 }
}
Another overload of that same method without the "value" argument can be used to get the current value of an item.

Best,
Stephen

User avatar
dekacko
Posts: 3
Joined: 07 Mar 2016, 11:50

Re: chagne project data from c# script

Post by dekacko » 24 Aug 2017, 12:32

Hi Stephen,

thank you very much for your help. works like a charm!

many thanks

Post Reply