Jump to content

vs.GetLName doesn't work


Recommended Posts

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

Link to comment

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 by twk
  • Like 1
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...