Jump to content
Developer Wiki and Function Reference Links ×

Vectorscript to Python Question


Cheth

Recommended Posts

I seem to be trying the same thing over and over again. I am trying to understand vs.ForEachObject criteria in terms of python.

For example, if I take this script in vectorscript

Var Light: Handle;

Procedure setname(conventional:Handle);

Begin

SetRField(conventional,'Lighting Device','Symbol Name','Conventional');

End;

Begin

ForEachObject(setname,(((PON='Lighting Device') & ('Lighting Device'.'Device Type'='Light'))));

End;

Run(setname);

And I want to move it to Python... I only get as far as,

import vs;

def setname(h):

vs.SetRField(h,"Lighting Device","Symbol Name","Conventional");

vs.ForEachObject(setname, ????)

I can't figure out the syntax to check for the device type in a lighting device that is equal to a value of Light.

I error out every time.

Link to comment

From Dev Wiki

def vs.ForEachObject(callback, c):
   return None

Try this..

import vs;

def setname(h):
vs.SetRField(h,"Lighting Device","Symbol Name","Conventional");

crit = "(((PON='Lighting Device') & ('Lighting Device'.'Device Type'='Light')))"
vs.ForEachObject(setname, crit)

Disclaimer:

Not Python expert :)

Link to comment

Dieter, this looks like an invaluable resource.

I am just getting my head stuck into python after losing sleep over VS.hehe.

People tell me python is good for file access/os access/external libraries galore/etc. So I'm slowly making the switch.

Your dlibrary modules, do we just download that straight from that website? Or is there a better way? Clone? what does that mean? Looks helpful, if I knew how to use it.lol

Thanks in advance

Tui

Link to comment

Your dlibrary modules, do we just download that straight from that website? Or is there a better way? Clone? what does that mean? Looks helpful, if I knew how to use it.lol

Thanks in advance

Tui

Well, you can download specific versions from the site. You can place the code where you want and it to the scripting paths in VW. In your script, you can then import the modules to use them. If you use an external editor, you can get syntax highlighting etc.

Did you read the readme and manual install files? There is some info in there on how to use it, but I still have to write a good step by step guide on how to use it properly with VW.

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