namespace adept - accessing a string inside a C# script

Tips and tricks for Adept ACE

namespace adept - accessing a string inside a C# script

Postby Joerg.Vogel » Mon May 15, 2017 3:56 am

I'm trying to get a string data from the ACE Workspace into a c# script in Emulation Mode. I found in the forum http://www.adept.com/forum/viewtopic.php?f=45&t=52: Calling C# Scripts from a V+ Module and I read the included post link inside it, too. Unfortunately the namespace "Adept" doesn't exists in my workspace, how can I get it into my workspace? Or is there a workaround to get a string inside a call of the remote execute program?

My ACE Version is 3.6.3.2

Many Thanks?

Regards Joerg
Joerg.Vogel
 
Posts: 10
Joined: Tue Dec 06, 2011 5:13 am

Re: namespace adept - accessing a string inside a C# script

Postby Joerg.Vogel » Mon May 15, 2017 5:33 am

The root namespace Adept has been moved to the space Ace.Adept.

Here is my script to exchange the color of a segment of an imported 3D shape:
Code: Select all
using Ace.Core.Server.Sim3d; // Color attribute of the imported 3D shape
                             // root path of the shape "/3D"
using Ace.Core.Server;// namespace definition
using Ace.Adept.Server.Controls; // Access to the Variables in the ACE Workspace
using System.Diagnostics;// Trace
using System.Drawing;// Converting String to Color Name, changing Color

namespace Ace.Custom {
   
   public class Program {
      
      public AceServer ace;

      public void Main () {
         // Change a color by Name of a string variable from Workspace ACE smart controller
         IAdeptController controller = ace.Root["/SmartController /SmartController "] as IAdeptController;
           // Workspace Path of the Controller
         string colourScript = controller.GetStringValue("$colors3d");
           // "$colred" is variablename of a "V+ User Variable"
         Trace.WriteLine("Script Starting - Trace Output");// Task Status Control output - Trace Messages
         Trace.WriteLine(colourScript);
         ICadData Ball =(ICadData) ace["/3D/Ball"];
           // Interface Class to the imported 3D shape (as a STL-File)
         Ball.Segments[0].Color = Color.FromName(colourScript); //   
           // Segment Color of the first segment
           // FromName a Method to convert implicitly the stored string value to a Color Name
         }            
      }
   }
Joerg.Vogel
 
Posts: 10
Joined: Tue Dec 06, 2011 5:13 am


Return to Adept ACE

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests