avictorgm Posted November 21, 2018 Share Posted November 21, 2018 Hello, No way to rename objects (rectangle or polygons) with: Even with 3D polygons the problem is the same. But If the element is a sphere it works. Why? vs.SetName() import vs ObjectName = vs.GetName(vs.FSActLayer()) vs.AlrtDialog(str(ObjectName)) SName = 'Fred' points = [0,0,-0.5,1,0.5,1.5,2,1,1,-0.5,0,0] h1 = vs.Poly(*points) vs.SetName(h1, SName) import vs X1 = 100 Y1 = 150 X2 = 0 Y2 = 500 NombreStand = 'Nombre' SName = vs.Concat(NombreStand) h = vs.Poly(0,0,X1,Y1,X2,Y2,0,0) h1 = vs.SetPolyClosed(h, 1) h2 = vs.MakePolygon(h1) vs.DSelectAll() vs.SetName(h2, SName) This one works perfect! import vs ObjectName = vs.GetName(vs.FSActLayer()) vs.AlrtDialog(str(ObjectName)) SName = 'Fred' h1 = vs.CreateSphere(0, 0, 0, 1000) vs.SetName(h1, SName) I am wondering if the problem is that are 2D elements, (that has no sense at all) Quote Link to comment
JBenghiat Posted November 21, 2018 Share Posted November 21, 2018 Not every function returns a handle — see the the function reference to check for return values. http://developer.vectorworks.net/index.php/VS:Function_Reference Most older functions, like Poly() do not. In those cases, get a handle to the last created object with: vs.LNewObj() Quote Link to comment
PatW Posted November 21, 2018 Share Posted November 21, 2018 (edited) def vs.Poly(p): return None Poly is not returning tha handle 😉 Look for the function LastCreatedObj or similiar to get the handle. Edit: To slow. But one addition if you want to make sure that LNewObj is giving you the right obj you can first execute LNewObj save the handle then create the poly, do LNewObj again and check if the result is not the same as from the first call. Edited November 21, 2018 by PatW 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.