+ Reply to Thread
Results 1 to 5 of 5

Thread: Automate Printing

  1. #1

    Automate Printing

    I have to print about 200 2d drawings, arranged one next to each other, on the same page format. Is there any way to do this with python?

    10x!

  2. #2
    Super Moderator Mitch's Avatar
    Join Date
    May 2010
    Location
    Switzerland
    Posts
    286
    Well, a lot will depend on how those 2D drawings are. Are they each a separate file? If so it should be possible to write a script to open/import each successive file in a folder, throw a bounding box around the drawing and center that in a standard rectangle and then add that to a layout - spacing it away from the last one and indexing over and down when the page width limit is reached. but it's a fair amount of work...

    --Mitch

  3. #3
    Hi Mitch, thanks for the reply. The drawings are in the same file, i just have to move the bounding box in X direction. I know it is a lot of work but i'm wandering what is faster, to print manually 200 drawings or to spend that time with the script.

  4. #4
    Hi bgdch

    Below is a trace of Python scripting.
    You must select the bounding rectangles as in the attached file.

    Python Code:
      import rhinoscriptsyntax as rs
      import Rhino
      riquadri=rs.GetObjects("seleziona riquadri disegni")
      object_list = rs.AllObjects()
      name="stp"
      n=1
      for riquadro in riquadri:
          rs.UnselectAllObjects()
          bb=rs.BoundingBox(riquadro)
          for obj in object_list:
              if rs.IsObjectInBox(obj, bb, False):
                  rs.SelectObject( obj )
          lista_di_stampa=rs.SelectedObjects()
          rs.Sleep(600)
          obs=rs.InvertSelectedObjects()
          object_list=obs
          rs.HideObjects(obs)
          rs.Command("-print _go")# to be completed with setup options
          Rhino.RhinoApp.Wait()
          #rs.Sleep(600)
          rs.ShowObjects(obs)

    I hope help you
    Ciao Vittorio
    Attached Files
    Last edited by vittorio; 08-19-2012 at 06:31 PM.

  5. #5
    This script works OK with my printer:

    Python Code:
      import rhinoscriptsyntax as rs
      import Rhino
      riquadri=rs.GetObjects("seleziona riquadri disegni")
      object_list = rs.AllObjects()
      for riquadro in riquadri:
          rs.UnselectAllObjects()
          bb=rs.BoundingBox(riquadro)
          for obj in object_list:
              if rs.IsObjectInBox(obj, bb, False):
                  rs.SelectObject( obj )
          lista_di_stampa=rs.SelectedObjects()
          rs.Sleep(600)
          obs=rs.InvertSelectedObjects()
          object_list=obs
          rs.HideObjects(obs)
          rs.Command("-print _S _D _p " + '"Epson ESC/P-R"'+ " _enter _enter  _g  _enter")# to be completed with setup options
          #Rhino.RhinoApp.Wait() # aspetta che termini la stampa prima di proseguire
          rs.Sleep(28000) # printing time about expected
          rs.ShowObjects(obs)
    Ciao Vittorio
    Last edited by vittorio; 08-19-2012 at 08:52 PM.

+ 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