Steven Morgan Posted November 29, 2021 Share Posted November 29, 2021 Done some digging around and haven't been able to find a way to accomplish something like the Edit>Duplicate Array tool through Vectorscript. Currently I have: Symbol(ledTypeName,0,0,0); ledFrame:=FSActLayer; GetBBox(ledFrame,p1X,p1Y,p2X,p2Y); N1:=3; N2:=3; IF (ledTypeID<3) THEN BEGIN for i := 1 to N1 do BEGIN ledFrameDup:= HDuplicate(ledFrame,((p2X-p1X)*i),0); END; for i := 1 to N2 do BEGIN ledFrameDup:= HDuplicate(ledFrame,0,((p2Y-p1Y)*i)); END; END ELSE BEGIN message('SACO'); END; This gives me my 3 columns across and 3 rows down. I just can't figure out how to loop through and fill in each column. Quote Link to comment
JBenghiat Posted November 29, 2021 Share Posted November 29, 2021 Are you always placing symbols? If so, rather than duplicating, you can just place the symbols with offset insertion points. Either way, you want nested sets of for loops: for row := 1 to rows do BEGIN for column := 1 to columns do BEGIN END END Pay attention to whether your index is 1-based or zero-based, depending on if you're inserting or duplicating. If you're duplicating, the columns loop would use ledFrameDup instead of ledFrame as the object you're duplicating. P.S. Take a look at surface arrays. That may already accomplish what you are trying to achieve. Quote Link to comment
Steven Morgan Posted November 29, 2021 Author Share Posted November 29, 2021 Thanks for the quick reply Josh, I am always placing Symbols so that makes way more sense. I've tried a few different combinations and either end up with a single symbol per row/column. Seems like I'm missing a simple step but for some reasons I just can't quite see my mistake. for row := 1 to rows do BEGIN for column := 1 to columns do BEGIN Symbol(ledTypeName,offsetX,OffsetY,0); END END Quote Link to comment
JBenghiat Posted November 29, 2021 Share Posted November 29, 2021 in the above example: x := origin.x + (column - 1) * symbolWidth y := origin.y + (row -1 ) * symbolHeight Quote Link to comment
Steven Morgan Posted November 29, 2021 Author Share Posted November 29, 2021 Ah that's perfect. Thanks again Josh Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.