Jump to content

# vex : addvertex with foreach

## Recommended Posts

Posted (edited)

What do these two lines mean? I do not understand. Please explain.

addvertex(0, prim, @ptnum);

addvertex(0,prim,pt);

I don't konw why "ptnum" is needed here.

Edited by jimsunglady

#### Share this post

##### Share on other sites

Because this foreach create a line between the point number @ptnum and a point from the list, here pt.

#### Share this post

##### Share on other sites
Posted (edited)

I don't understand. Is pt different from @ptnum?

Isn't list a list of @ptnum?

Edited by jimsunglady

#### Share this post

##### Share on other sites
8 hours ago, jimsunglady said:

I don't understand. Is pt different from @ptnum?

Isn't list a list of @ptnum?

First of all, VEX function run on  all points at the same time.

nearpoints() put in a list, all points found from the current point position in 2 m radius.

For exemple for point number 0 :

@list =[0,2,3,7]

Then foreach will run over each point in this list, with variable pt (int pt)

Exemple for the second loop :

@ptnum = 0

pt= 2

The third loop:

@ptnum = 0

pt = 3

Be aware than nearpoints() will always return the actual point (@ptnum) as the first of the list. So in your case,  you will get some lines with the same point for each point in your geometry:

The first loop:

@ptnum = 0

pt = 0

thank you !

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now

×
• Donations

• Leaderboard