Bertf Posted February 2, 2016 Share Posted February 2, 2016 Hi, When using a function like vs.SetTextFont(objectHd, Start, Count, FontNum), I need an object handler (objectHd) that points to the textbox of which the function has to change the font. my code: h = vs.CreateText('Hello') vs.SetTextFont(h, 0, vs.GetTextLength(h), vs.GetFontID('Arial')) This gives the error: Handle to text object is not valid. What am I doing wrong? :confused: The output of createText is a Handle and the SetTextFont asks for a handler? Thank you! Bert Quote Link to comment
Marionette Maven Marissa Farrell Posted February 2, 2016 Marionette Maven Share Posted February 2, 2016 So actually, in this case, vs.CreateText() does NOT return a handle, it returns None. Here's a script that should work for you instead. vs.CreateText('Hello') h = vs.LNewObj() vs.SetTextFont(h, 0, vs.GetTextLength(h), vs.GetFontID('Arial')) Hope this helps! Quote Link to comment
Bertf Posted February 2, 2016 Author Share Posted February 2, 2016 Thank you very much Marissa! Works like a charm now Quote Link to comment
JBenghiat Posted February 2, 2016 Share Posted February 2, 2016 Not every object creation routine returns a handle, though some do, and some return multiple handles. Check the function reference to see if the command returns a handle, boolean, or None. You should usually be able to get a handle wiht LNewObj() as above. http://developer.vectorworks.net/index.php/VS:Function_Reference -Josh Quote Link to comment
Dieter @ DWorks Posted February 4, 2016 Share Posted February 4, 2016 Or use https://bitbucket.org/dieterdworks/vw-dlibrary, which has creation functions that always returns an object for you to use. It's open source, and you can help add to it. 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.