[MACRO] Polyworks Looping

Discuss PolyWorks software here.
Post Reply
User avatar
TK.421
I have made <0 posts
I have made <0 posts
Posts: 9
Joined: Wed Aug 22, 2018 7:54 pm
5
Full Name: David Adam
Company Details: Accurate Pattern
Company Position Title: peon
Country: US
Linkedin Profile: No
Has thanked: 2 times

[MACRO] Polyworks Looping

Post by TK.421 »

Due to a lack of a user forum on Innovmetric's website, I'm hoping this user forum is frequented often!

I have a bunch of comparison points divided up into a number of groups. I have all my groups in a list. I'm not familiar with the syntax of the poylworks macro language though. I've looked through the macro commands help and I cant find what I'm looking for. I dont see any available commands to do a FOR EACH loop. How would I go about looping through each group of comparison points? The end game is changing the name of the first item in each group along with some of the geometric controls.

Here's what I have so far:

Code: Select all

DECLARE numOfGrps 
DECLARE grpName  
DECLARE itmName
DECLARE i 1


TREEVIEW OBJECT_ELEMENTS SELECT NONE

TREEVIEW OBJECT_GROUP COUNT GET ( numOfGrps )
TREEVIEW OBJECT_GROUP NAME ALL GET ( grpName )

WHILE $i <= $numOfGrps 
    
    ### this is where I want to get the 1st item name of each group to variable $itmName ###
    
    MACRO PAUSE ( $grpName[$i] )  # returns group name
    
    ++i    
ENDWHILE
Thanks in advance!
User avatar
TK.421
I have made <0 posts
I have made <0 posts
Posts: 9
Joined: Wed Aug 22, 2018 7:54 pm
5
Full Name: David Adam
Company Details: Accurate Pattern
Company Position Title: peon
Country: US
Linkedin Profile: No
Has thanked: 2 times

Re: [MACRO] Polyworks Looping

Post by TK.421 »

So here's the way to do it if anyone ever runs into this particular problem:

Code: Select all

DECLARE count
DECLARE name
DECLARE itemName
DECLARE i 1

TREEVIEW OBJECT_GROUP COUNT GET ( count )
TREEVIEW OBJECT_GROUP NAME ALL GET ( name )


while $i <= $count
    TREEVIEW OBJECT SELECT NONE
    TREEVIEW OBJECT_GROUP SELECT ($name[$i])

    TREEVIEW COMPARISON_POINT NAME SELECTED GET ( itemName )
    TREEVIEW OBJECT SELECT NONE
    TREEVIEW OBJECT SELECT ("$itemName[1]")
    
    MACRO PAUSE ( "$itemName[1]" ) #used as a print command to check results
    
    ++ i
ENDWHILE
Last edited by TK.421 on Thu Aug 23, 2018 9:07 pm, edited 1 time in total.
User avatar
Jason Warren
Administrator
Administrator
Posts: 4224
Joined: Thu Aug 16, 2007 9:21 am
16
Full Name: Jason Warren
Company Details: Laser Scanning Forum Ltd
Company Position Title: Co-Founder
Country: UK
Skype Name: jason_warren
Linkedin Profile: No
Location: Retford, UK
Has thanked: 443 times
Been thanked: 246 times
Contact:

Re: [MACRO] Polyworks Looping

Post by Jason Warren »

Nice one, thank you for posting ... ;)
Jason Warren
Co_Founder

Dedicated to 3D Laser Scanning
LaserScanningForum
User avatar
NOVAMECH
V.I.P Member
V.I.P Member
Posts: 279
Joined: Wed Aug 04, 2010 5:43 am
13
Full Name: Nick Bush
Company Details: NOVAMECH
Company Position Title: Director
Country: New Zealand
Skype Name: novamech5
Linkedin Profile: Yes
Location: Auckland, New Zealand
Has thanked: 9 times
Been thanked: 9 times
Contact:

Re: [MACRO] Polyworks Looping

Post by NOVAMECH »

Thanks, for Posting on the POLYWORKS Tab. We need more. I was just trying out the MACRO function yesterday
mlacht
I have made <0 posts
I have made <0 posts
Posts: 5
Joined: Thu Apr 11, 2019 1:57 pm
4
Full Name: Markus
Company Details: student
Company Position Title: student
Country: Germany
Skype Name: -
Linkedin Profile: No
Been thanked: 1 time

Re: [MACRO] Polyworks Looping

Post by mlacht »

How can I simply print something (as mentioned above) ?

I tried with:

Code: Select all

DECLARE i 1
MACRO PAUSE ( $i )

But this gives me a syntax error
mlacht
I have made <0 posts
I have made <0 posts
Posts: 5
Joined: Thu Apr 11, 2019 1:57 pm
4
Full Name: Markus
Company Details: student
Company Position Title: student
Country: Germany
Skype Name: -
Linkedin Profile: No
Been thanked: 1 time

Re: [MACRO] Polyworks Looping

Post by mlacht »

Printing in Polyworks:

Code: Select all

MACRO ECHO ( "For console log here?" )
Post Reply

Return to “PolyWorks”