Jump to content
Developer Wiki and Function Reference Links ×

create linear object (renderworks camera) from script.


Will

Recommended Posts

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

Link to comment

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 by Will
Link to comment

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?

Link to comment
  • Vectorworks, Inc Employee

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 by Matt Panzer
Link to comment

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

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...