+ Reply to Thread
Results 1 to 9 of 9

Thread: BatchProcessor

  1. #1
    Super Moderator Mitch's Avatar
    Join Date
    May 2010
    Location
    Switzerland
    Posts
    286

    BatchProcessor

    Hi all,

    I was trying to sketch out a batch process...

    python Code:
      import rhinoscriptsyntax as rs
       
      def BatchSketch():
          files=rs.OpenFileNames("BatchProcess","Rhino files|*.3dm||")
          if not files: return
         
          for file in files:
              file='"'+file+'"'
              rs.Command("_-Open "+file)
              #The following works:
              rs.Command("_Line 0 10,0,0")
              #But this doesn't:
              #rs.AddLine([0,0,0],[10,0,0]) #or any other add geometry method
              rs.Command("_-Save _Enter")
      BatchSketch()

    Can anyone tell me why the rs methods don't work in this case? I get a message that it is unable to add the geometry to the document. It seems that it's not accepting the current document as the active document if I step into the method...

    --Mitch

  2. #2
    Super Moderator Mitch's Avatar
    Join Date
    May 2010
    Location
    Switzerland
    Posts
    286
    -- anyone?

  3. #3
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,464
    Blog Entries
    19
    Sorry, got behind on support this last week. This looks like a bug in my logic inside the the script execution engine. I'll get this fixed as soon as possible.
    -Steve

  4. #4
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,464
    Blog Entries
    19
    Just to make sure my assumptions are correct I want to make sure I understand what you would expect in a multi-doc type system (like Mac Rhino). I'm assuming that you would expect the line to be created in the document that was just opened. Is that correct?

    Thanks,
    -Steve

  5. #5
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,464
    Blog Entries
    19
    Ok, the next V5 beta should work with your script.
    -Steve

  6. #6
    Awesome Mitch, glad you started to take a look at this. I had just started looking at it last night.

    So I have an super basic question. My logic followed something similar to what you wrote, if you wanted to edit a certain rhino file through python scripting you would do a

    rs.command( "_open")

    do something

    rs.command("_save)

    My question is do you need to mess with a the python file object, open(), in this situation or can you do what's listed above without a file object?

    Thanks

    Dennis

  7. #7
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,464
    Blog Entries
    19
    Mitch's sample should work just fine in the next V5 beta. You shouldn't have to deal with python file objects.
    -Steve

  8. #8
    Sweet. Thanks.

  9. #9
    So this is my attempt in Python to recreate a batch folder process in this link here. With the exception I need to run an existing python script on multiple files. Let me know if you see anything wrong or could be improved on as I new to python/scripting.

    http://wiki.mcneel.com/developer/scr...convertautocad

    Python Code:
      def batchprocess():
          sFolder=rs.BrowseForFolder(None,"Select folder to process","Batch")
          if sFolder is None:
              pass
          else:
              filename = os.listdir(sFolder)
              for file in filename:
                  if file.endswith(".3dm"):
                      path = os.path.join(sFolder,file)
                      rs.Command("_-Open " + path)
                      #Add Custom Python Script Here#
                      AddLineTest.AddLine()
                     
                      rs.DocumentModified(False)
                      rs.Command("_Save")
                     
              rs.DocumentModified(False)
              rs.Command("_-New _None")
       
      batchprocess()

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts