Site Logo
Site Logo
 
It is currently Sun Apr 02, 2017 10:21 pm

All times are UTC [ DST ]




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Splitting string to a list
PostPosted: Wed Jan 13, 2016 2:07 pm 
Offline
DELCAM User
DELCAM User

Joined: Tue Feb 17, 2015 7:15 pm
Posts: 29
Hello,

I have problem which is that the macro command: Let $Electrodes = electrodes.list.originals; Outputs the electrodes in string type and not as list.

How can I split the electrode names on the string "list" into separate indexes on a list?


Top
 Profile  
 
 Post subject: Re: Splitting string to a list
PostPosted: Wed Jan 13, 2016 3:20 pm 
Offline
Site Admin
User avatar

Joined: Wed Sep 22, 2004 1:36 pm
Posts: 625
Location: Birmingham, UK
You can use the list commands to create proper macro lists.

Code:
// find the number of electrodes in the model
LET num_elect = electrode.number

// create empty lists
LIST elect_copies = { }
LIST electr_orig = { }

// loop through the electrodes to split into lists of copies and originals
LET i = 1
LET carry_on = ($i <= $num_elect)

WHILE $carry_on {
  //find the electrode name
  LET nam = electrode[index $i].name

  // find the datum of the electrode
  LET elect_copy = electrode[index $i].is_copy

  IF $elect_copy {
    LIST_ADD $elect_copies END $nam
  } ELSE {
    LIST_ADD $electr_orig END $nam
  }

  LET i = $i + 1
  LET carry_on = ($i <= $num_elect)
}

p 'copies '$elect_copies
p 'originals '$electr_orig

// loop through the electrode lists to find information on the electrodes

LET num_elect_orig = electrode.number.originals
LET i = 1
LET carry_on = ($i <= $num_elect_orig)

WHILE $carry_on {
  //find the electrode name
  LET nam_orig = $electr_orig[$i]

  // find level of electrode
  LET elec_lev = electrode[$nam_orig].level
  PRINT 'level of electrode '$nam_orig ' is '$elec_lev

  LET i = $i + 1
  LET carry_on = ($i <= $num_elect_orig)
}


Top
 Profile  
 
 Post subject: Re: Splitting string to a list
PostPosted: Thu Jan 14, 2016 10:47 am 
Offline
DELCAM User
DELCAM User

Joined: Tue Feb 17, 2015 7:15 pm
Posts: 29
Yes this would do the trick though a bit long way :)

Anyway I should have noted that Im using CSC and now Im having problems running the macro from VB. I believe I need to use the RunComplete method to get PowerSHAPE run the macro correctly with IF/WHILE conditions, but I cant figure out how to define the macro path to PSMacro class variable?


Top
 Profile  
 
 Post subject: Re: Splitting string to a list
PostPosted: Thu Jan 14, 2016 12:40 pm 
Offline
DELCAM Staff
DELCAM Staff

Joined: Tue Mar 17, 2009 2:30 pm
Posts: 108
You should use the following code to achieve this:
Code:
var macro = powerSHAPE.LoadMacro(new Delcam.FileSystem.File("c:\files\mymacro.mac"));
macro.RunComplete();

The next version of Custom Software Core will include support for reading these electrode properties. Would you be interested in trying out the beta version of it? If so then please email me at bespokesupport@delcam.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB