Jump to content

Insert Symbol as grid/matrix


Recommended Posts

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.

 image.png.7c29317097d6288bb68ea6f6923cd8aa.png

Link to comment

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.

Link to comment

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

image.png.6da8a882361fc4e97459b9f187f0a598.png

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...