matteoluigi Posted February 22, 2022 Share Posted February 22, 2022 Hi, I don't understand, why the GetLname-Function in the following code doesn't work, the GetClass-Function instead does work. Both functions work with a Handle (HNDL) and return a String value. def CalledProc(HNDL): # LNR=vs.GetClass(HNDL) LNR=vs.GetLName(HNDL) vs.SetRField(HNDL,'l-test','layer',LNR) vs.ForEachObject(CalledProc,"(T=RECT)") vs.AlrtDialog('done') I attached a small vwx 2022 file with a few rectangles and a python script with the posted code which (as you can read) reads out the class name or the layer name and writes it into the record format field "layer" from the record format "l-test". any idea why GetClass works and GetLName instead doesn't? I tried the function in other scripts, of course, too, without any differences... GetLName.zip Quote Link to comment
twk Posted February 22, 2022 Share Posted February 22, 2022 (edited) GetLName returns the name of the referenced layer, eg. # the current design layer name = 'Layer 1' # to get a handle to the active layer, you'd use vs.ActLayer() layername = vs.GetLName(vs.ActLayer()) vs.AlrtDialog(layername) # should display 'Layer 1' I think what you're after is vs.GetLayer(HNDL). https://developer.vectorworks.net/index.php/VS:GetLayer and then vs.GetLName eg h = vs.FSActLayer() layer_name = vs.GetLName(vs.GetLayer(h)) # vs.GetLayer(h) returns a HANDLE to the layer the object 'h' belongs to Edited February 22, 2022 by twk 1 Quote Link to comment
Pat Stanford Posted February 22, 2022 Share Posted February 22, 2022 Layers in Vectorworks are in a different "Name List" than the other objects. That is why you can have a Layer and a Class both with the same name. But it means that to get the layer name you have to send a handle to the LAYER to GetLName. @twk has given you the right answer on how to get it. 1 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.