Nirtec Studio Forum

General Category => Machines Simulator => Topic started by: jvblade on August 03, 2025, 04:47:34 PM

Title: Access UDC 3D text component when added to a machine
Post by: jvblade on August 03, 2025, 04:47:34 PM
I have a UDC component that is added to my machine. The UDC component has a 3D text component called "KG". I need to change the text value from my machine code script. How do I address this component in the script code to change the text value?
Title: Re: Access UDC 3D text component when added to a machine
Post by: EasyPLC_Master on August 04, 2025, 08:21:51 AM
Using script code, use the Text property of the component to change fot the desired text:

Text 3D:
string Text -> Sets the text message
Color TextColor -> Sets the text color
void Visible(bool value) -> View/hide the Text effect
Title: Re: Access UDC 3D text component when added to a machine
Post by: jvblade on August 06, 2025, 03:45:56 AM
Ok, yes I am familiar with how to change the text when it is one component. However, I am adding 4 UDCs of the same type in my machine project. So I would like to know how to change the script code in the main machine project so that I can change the 3D text in each of these UDCs?

As an example I have:

UDC1, UDC2, UDC3, UDC4
each of these has a 3D text called "KG"

How would I change the .text of each of these in the script code of the main project?

Thanks
Title: Re: Access UDC 3D text component when added to a machine
Post by: EasyPLC_Master on August 06, 2025, 08:13:47 AM
If you want to change dinamically the text of a Text3D component located in an UDC, you must use the Parameter Text property.

An example:

In your UDC (In Edit Parameters, create one called Text)
string txt = "";

public void Init()
{
 
}

public void Main()
{
txt = UC.GetParameterText("Text");
Text3D.Text = txt;
}

public void Physics()
{

}

public void Finish()
{
 
}


In the machine where are used the UDCs (here is supposed to have three UDCs called U1, U2 and U3):
public void Init()
{
 
}

public void Main()
{

if(IOManager.GetOutput(0))
{
U1.SetParameter("Text", "Your Text 1 here");
U2.SetParameter("Text", "Your Text 2 here");
U3.SetParameter("Text", "Your Text 3 here");
}
}

public void Physics()
{

}

public void Finish()
{
 
}
Title: Re: Access UDC 3D text component when added to a machine
Post by: jvblade on August 06, 2025, 02:55:21 PM
Thank you. This is a big help. It especially points me to the area in the manual that gives me the additional functions that I can use.