VC plibraries in python

I have wrote a code using the VC libraries imported on pthon and methods in these libraries.
Would this code still run if I used it on another program or another python platform?

No, then you’re missing the VC libraries, which are bundled together with the Visual Components software. You can’t use them outside the Visual Components software. Some modules are plain python files and some of them are compiled dlls.

If you want to reuse code outside of VC, then you have to isolate your code from the rest of VC. This is a common technique often used.

Put your code in a different module and place it in C:\Users\USERNAME\Documents\Visual Components\4.2\My Commands\

This directory is in sys.path. To get your path, you could call following code in your PythonScript:

import sys

And here an example of a module:

def complex_function():
    return 42

class Foo(object):

foo_instance = Foo()

I have called it “”. In my case, it’s in C:\Users\Admin\Documents\Visual Components\4.2\My Commands\

Then you create a Python script in your component and import what you need:

from __future__ import print_function
from vcScript import *

from my_module import complex_function, foo_instance

def OnSignal( signal ):

def OnRun():

In this part you can use your code in your VC-Application and you could also use your “my_module” somewhere else outside of VC.

So how can I use the methods of pick and place objects by robots outside VC?
Will i have to manually write these methods?

It depends on the framework, where you are working with.
If you’re working with Blender, then you have to use the functions and methods from Blender and not VC.

That is what I mean. You need to abstract your code.

For example, you’ve a function to calculate positions in a high-rack-bays.
You can do this completely without any dependency to Visual Components.
This code can run outside of VC without any modification (Python 2.7).

But if you’ve written code to grab a Component (from or to Container, Path), then this is related to Visual components. If you want to use this same code in another software/environment, you’ve to create a wrapper around all VC-Code you use and you have to find functions/methods in the new environment, which have to be used to control the 3D-World.

This will definitely be taken into my condiseration.
Thanks for the help.