Start a new topic
Answered

Switchable Cameras during Simulation

Greetings everyone!


I am working on a remote camera display for crane simulation. It will display 4 perspective cameras in one monitor. I believe that I can`t switch the cameras once it was saved in .vxc file. So my option is to create a script in Editor to allow an active camera to switch its views.


image


I am new on this programming. Do someone know how to complete this script for changing cameras? Kindly guide me on this.


image


Regards,

Mark


py

Best Answer

The basic logic of the script looks like it should work fine. When I try running your attached file, there is a syntax error:


  File "<string>", line 11

def pre_step(self):

^

IndentationError: expected an indented block


You have all the code in the on_remove_from _universe function commented, so the function is empty and expects some code. If you just add a "pass" statement at the end of the function, it should work. 



Martin


Answer

The basic logic of the script looks like it should work fine. When I try running your attached file, there is a syntax error:


  File "<string>", line 11

def pre_step(self):

^

IndentationError: expected an indented block


You have all the code in the on_remove_from _universe function commented, so the function is empty and expects some code. If you just add a "pass" statement at the end of the function, it should work. 



Martin

Hi Martin,


I don`t notice this one . Thank you for the help!

After adding pass statement, another syntax error displays - it talks about the getValue().


I replace it with "value" and it works.


Thank you for the guidance. I appreciate it.


Regards,

Mark

Python language is a very sensitive language for indentation, it has caused confusion for many beginners. Putting in an extra space or leaving one out where it is needed will surely generate an error message . Some common causes of this error include:

 

  • Forgetting to indent the statements within a compound statement
  • Forgetting to indent the statements of a user-defined function.

 

The error message IndentationError: expected an indented block would seem to indicate that you have an indentation error. It is probably caused by a mix of tabs and spaces. The indentation can be any consistent white space . It is recommended to use 4 spaces for indentation in Python, tabulation or a different number of spaces may work, but it is also known to cause trouble at times. Tabs are a bad idea because they may create different amount if spacing in different editors .

 



1 person likes this

Absolutely. Very valuable input. Thank you.

Login to post a comment