Page 1 of 1
chagne project data from c# script
Posted: 22 Aug 2017, 16:27
by dekacko
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
Re: chagne project data from c# script
Posted: 23 Aug 2017, 09:24
by stephen
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
Re: chagne project data from c# script
Posted: 24 Aug 2017, 12:32
by dekacko
Hi Stephen,
thank you very much for your help. works like a charm!
many thanks