Jump to content

set active a rectangle


Recommended Posts

Hello again,

 

I have. a code to go thru every element / symbol in my layer until it finds a rectangle.

then, I just need to get selected only this element.

 

A) I use X = 10 just to put a number. I need to count the number of elements.

 

the script works well until B) where it doesn't get the rectangle to zoom it whit the next line

 

Some ideas?

import vs
x = 10;
#-A)----------I need to count the number of objects in the layer

#vs.AlrtDialog(vs.Concat('Nr of objects is: ',  ***Count of all the elements in the layer*** ))
vs.DSelectAll

vs.LActLayer()

OBJETO = vs.LActLayer()
SymbolName = vs.GetSymName(OBJETO)

while x > 0:
	ElementTYPE = vs.GetType(OBJETO)
	if ElementTYPE == 15:
		SymbolName = vs.GetSymName(OBJETO)
		vs.AlrtDialog(vs.Concat(str(ElementTYPE), " Name: ", str(SymbolName)))
		#vs.AlrtDialog(vs.Concat('Object is a ', objectTypes[vs.GetType(h)]))
	
	
	if ElementTYPE == 3:
		
		vs.AlrtDialog(str('Recuadro encontrado'))
		vs.AlrtDialog(str(ElementTYPE))
		#B).........I wanna set active the rectangle
		vs.GetObject()
		vs.DoMenuTextByName('Fit To Objects', 0);
		
		break
	
	OBJETO = vs.PrevObj(OBJETO)
	
	x = x - 1

 

Link to comment

Three modifications that should help:

 

Don’t forget the parentheses in vs.DSelectAll()

 

Instead of using the arbitrary x to govern the loop, use:

while OBJECTO != 0:

This will both ensure the script loops through all objects and prevent error if the number of objects is less than 10. 

Technically, the check should be OBJECTO != vs.Handle(0)

 

vs.GetObject() returns the handle to a named object and should take a string as its parameter. What you want is:

vs.SetSelect(OBJECTO)

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...