Will Posted June 5, 2014 Share Posted June 5, 2014 Hi All, I'm trying to create a Renderworks Camera from script like this: pos = (0,0,0) ang = 45 vs.MoveTo(pos) v = vs.Ang2Vec(ang, 1000000) vs.LineTo( pos[0]+v[0], pos[1]+v[1] ) path = vs.LNewObj() cam = vs.CreateCustomObjectPath( "Renderworks Camera", path, None) But I get this error: Error on line=1: _313 _60 - The object described has zero size. It cannot be created Error on line=1: _218 _224 - Error trying to convert string to number. And then a camera is created which appears to be based on a line length of 0 and has various problems when I try to use it. Can anyone see what I'm doing wrong? Is a line the wrong kind of path to use for creating a linear object? Should I be using CreateCustomObjectPath or CreateCustomObjectN, both have similar errors? Thanks for any help Will Quote Link to comment
Miguel Barrera Posted June 6, 2014 Share Posted June 6, 2014 I do not know the python syntax but is None equal to NIL (empty handle) in vectorscript? Also, there might be parameters that need to be initialized with SetRField(cam,recName,fldName,fldValue). Quote Link to comment
Will Posted June 7, 2014 Author Share Posted June 7, 2014 (edited) Thanks for replying. None is the python language 'null object' so I'm guessing its equivalent to NIL but I'm not sure as it's not really documented anywhere, so far as I can tell. The vector script example on the page for CreateCustomObjectPath shows NIL as the argument for this function, I'm not sure what a renderworks camera would use a profile group for is so I'm guessing I don't need one but don't know for sure. I'll try setting various fields using SetRField. I'm not sure what fields I can set that will help with the zero length camera object though. I'll also try the same script in vector script and see what happens. Thanks W Edited June 7, 2014 by Will Quote Link to comment
Will Posted June 7, 2014 Author Share Posted June 7, 2014 So I tried this vectorscript and the result is the same: PROCEDURE Example; VAR h1: HANDLE; BEGIN MoveTo(0,0); LineTo(100,100); h1 := CreateCustomObjectPath('Renderworks Camera', LNewObj, NIL); END; RUN(Example); Anyone got any ideas? Is it a bug? Quote Link to comment
Vectorworks, Inc Employee Matt Panzer Posted June 7, 2014 Vectorworks, Inc Employee Share Posted June 7, 2014 (edited) Hi Will, CameraMatch has a "Place RW Camera" feature and I remember issues like this when placing them via Vectorscript. The problem is that the RW Camera initializes some settings when it's first placed and this initialization is not done when inserting via vectorscript. The only way I could make it work correctly is to place a VW file (containing a red symbol of a newly placed RW Camera) in the same location as the plug-in file. Then have the script look for the symbol in the active file. If not present, it imports it from the external file, places it as needed, and sets the parameters via SetRField. Edited June 7, 2014 by Matt Panzer Quote Link to comment
JBenghiat Posted June 11, 2014 Share Posted June 11, 2014 The RW camera object is a linear object, so you would use CreateCustomObjectN, not the path-based calls. The line in a linear PIO isn't saved as a path, but merely an added parameter called LineLength. The direction of the line comes from the object's rotation. Therefor, to place a linear PIO based on a line via a script: - use vectors (or object info commands) to get the angle and magnitude of your line - insert the PIO like a point PIO, using the calculated rotation - Set the LineLength parameter (don't forget Num2StrF) As Matt remarked, PIOs don't run object initialization routines when placed via a script. There may be certain initial calculations and data inserted into hidden fields that your script may need to mimic. -Josh 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.