avictorgm Posted November 9, 2018 Share Posted November 9, 2018 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 Quote Link to comment
JBenghiat Posted November 9, 2018 Share Posted November 9, 2018 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) 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.