Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6010071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:03:50+00:00 2026-05-23T02:03:50+00:00

I am trying to edit a single line in a povray file using python.

  • 0

I am trying to edit a single line in a povray file using python.

The file starts out like so:

camera {
 angle 38
 location <500,0,0>
 right x*image_width/image_height
 look_at <0,0,0>
 rotate <0,0,0>
}

and I want to edit the variables described in the file so it comes out like this:

camera {
 angle 38
 location <1000,1000,1000>
 right x*image_width/image_height
 look_at <10,10,10>
 rotate <30,30,30>
}

To do this I am using the following method:

def updateCamera(self, filename):
        tmp = "povrayContent/temp.pov"
        lines = open(filename, 'r')
        out = open(tmp , 'w')
        for line in lines:
            if " angle" in line:
                out.write(" angle "+str(int(self.camAngle))+"\n")
            elif " location" in line:
                out.write(" location <"+str(int(self.camera[0]))+","+str(int(self.camera[1]))+","+str(int(self.camera[2]))+">\n")
            elif " look_at" in line:
                out.write(" look_at <"+str(int(self.camera[3]))+","+str(int(self.camera[4]))+","+str(int(self.camera[5]))+">\n")
            elif "rotate" in line:
                out.write(" rotate <"+str(int(self.camera[6]))+","+str(int(self.camera[7]))+","+str(int(self.camera[8]))+">\n")
            else:
                out.write(line)
        shutil.copy(tmp, filename)

EDIT: Camera is a tuple that contains the new values the variables should be changed to.
For the most part this seems to work. The only problem is that after the camera declaration there are about 40k lines of other declarations of objects in the scene. The problem I am having is that the last 20 or so lines of declarations are missing from the new file. Does anybody know what is going on, is there some limitation of python I am unaware of?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:03:51+00:00Added an answer on May 23, 2026 at 2:03 am

    Either flush or close the temporary file before copying to be certain that all output has been written to disk.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to draw a single line using OnMouseMove() event. My Problem is that
I'm trying to single source a form page which can be in edit mode
I'm trying to enter edit mode on a specific cell like this: void MainWindow::on_addButton_released()
I'm trying to edit configuration file in Java. What I really need to do
I'm using php to take xml files and convert them into single line tab
I'm trying to edit the output joomla main_menu module so I can make a
I'm trying to edit a textbox's text in a Page_Load form on an ASP.NET
I am trying to edit a record. I have the default route. When I
I have a relatively big SSIS package which I'm trying to edit. I basically
I'm trying to get edit-and-continue working with Visual Studio 2008 with an ASP.Net MVC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.