View Single Post
 
Old 12-19-2011, 12:57 PM
papersmithforge's Avatar
papersmithforge papersmithforge is offline
Member
 
Join Date: Feb 2011
Posts: 90
Total Downloaded: 0
The boundary rectangle this creates is approximately that size Maltedfalcon, a little bit wider (7.6875 in) and a little bit shorter (10.21875 in) offset 9/32 of an inch from the upper left corner both vertically and horizontally. Of course the script is simple enough to understand where you could modify it to work with values you choose. The ones used by default are those that were made available by the people who participated in the prior thread and by reading through some technical specs. The specifically generated rectangles save me the work of trying to remember the fractional parts and offsets.

Code:
Option Explicit
'Script written by <insert name>
'Script copyrighted by <insert company name>
'Script version Sunday, December 11, 2011 10:52:20 AM

Sub UniversalPrintableArea()
    Rhino.EnableRedraw(False)
    
    'Declare variables
    Dim topMargin, leftMargin, rightMargin, bottomMargin
    Dim pageWidth, pageHeight, innerWidth, innerHeight
    Dim upperCorner, helpCorner(3)
    Dim boundaryLines
    Dim viewPort
    Dim unitSystem
    
    unitSystem = Rhino.UnitSystem
    
    'Prompt for upper left corner of printable area'
    upperCorner = Rhino.GetPoint("Corner of print area")
    If IsNull(upperCorner) Then Exit Sub
    
    Select Case unitSystem
        Case 8    'Inches
            topMargin = 9.0/32.0
            leftMargin = 9.0/32.0
            rightMargin = 17.0/32.0
            bottomMargin = 0.5
            pageWidth = 8.5
            pageHeight = 11
        Case Else    'Assumes millimeters
            topMargin = 7
            leftMargin = 8
            rightMargin = 7
            bottomMargin = 30
            pageWidth = 210
            pageHeight = 297
    End Select
    
    innerWidth = pageWidth - leftMargin - rightMargin
    innerHeight = pageHeight - topMargin - bottomMargin
    
    boundaryLines = Rhino.AddGroup()
    viewPort = Rhino.CurrentView()
    
    Select Case viewPort
        Case "Front"    ' X's are positive Z's are negative
            helpCorner(0) = Rhino.PointAdd(upperCorner, Array(innerWidth, 0, 0))
            helpCorner(1) = Rhino.PointAdd(upperCorner, Array(0, 0, -innerHeight))
            helpCorner(2) = Rhino.PointAdd(upperCorner, Array(innerWidth, 0, -innerHeight))
        
            Call Rhino.AddObjectToGroup(Rhino.AddLine(upperCorner, helpCorner(0)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(upperCorner, helpCorner(1)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(0)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(1)), boundaryLines)
        
            upperCorner = Rhino.PointAdd(upperCorner, Array(-leftMargin, 0, topMargin))
            'Draw 1 inch scale box
            'helpCorner(0) = Rhino.PointAdd(helpCorner(2), Array(0, 0, 1))
            'helpCorner(1) = Rhino.PointAdd(helpCorner(2), Array(-1, 0, 0))
            'helpCorner(2) = Rhino.PointAdd(helpCorner(2), Array(-1, 0, 1))
        
            'Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(0)), boundaryLines)
            'Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(1)), boundaryLines)
        
            helpCorner(0) = Rhino.pointAdd(upperCorner, Array(pageWidth, 0, 0))
            helpCorner(1) = Rhino.pointAdd(upperCorner, Array(0, 0, -pageHeight))
            helpCorner(2) = Rhino.pointAdd(upperCorner, Array(pageWidth, 0, -pageHeight))
        
            Call Rhino.AddObjectToGroup(Rhino.AddLine(upperCorner, helpCorner(0)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(upperCorner, helpCorner(1)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(0)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(1)), boundaryLines)
        Case "Right"    ' Y's are positive Z's are negative
            helpCorner(0) = Rhino.PointAdd(upperCorner, Array(0, innerWidth, 0))
            helpCorner(1) = Rhino.PointAdd(upperCorner, Array(0, 0, -innerHeight))
            helpCorner(2) = Rhino.PointAdd(upperCorner, Array(0, innerWidth, -innerHeight))
        
            Call Rhino.AddObjectToGroup(Rhino.AddLine(upperCorner, helpCorner(0)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(upperCorner, helpCorner(1)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(0)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(1)), boundaryLines)
        
            upperCorner = Rhino.PointAdd(upperCorner, Array(0, -leftMargin, topMargin))
            'Draw 1 inch scale box
            'helpCorner(0) = Rhino.PointAdd(helpCorner(2), Array(0, 0, 1))
            'helpCorner(1) = Rhino.PointAdd(helpCorner(2), Array(0, -1, 0))
            'helpCorner(2) = Rhino.PointAdd(helpCorner(2), Array(0, -1, 1))
        
            'Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(0)), boundaryLines)
            'Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(1)), boundaryLines)
        
            helpCorner(0) = Rhino.pointAdd(upperCorner, Array(0, pageWidth, 0))
            helpCorner(1) = Rhino.pointAdd(upperCorner, Array(0, 0, -pageHeight))
            helpCorner(2) = Rhino.pointAdd(upperCorner, Array(0, pageWidth, -pageHeight))
        
            Call Rhino.AddObjectToGroup(Rhino.AddLine(upperCorner, helpCorner(0)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(upperCorner, helpCorner(1)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(0)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(1)), boundaryLines)
        Case Else    ' X's are positive Y's are negative
            helpCorner(0) = Rhino.PointAdd(upperCorner, Array(innerWidth, 0, 0))
            helpCorner(1) = Rhino.PointAdd(upperCorner, Array(0, -innerHeight, 0))
            helpCorner(2) = Rhino.PointAdd(upperCorner, Array(innerWidth, -innerHeight, 0))
        
            Call Rhino.AddObjectToGroup(Rhino.AddLine(upperCorner, helpCorner(0)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(upperCorner, helpCorner(1)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(0)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(1)), boundaryLines)
        
            upperCorner = Rhino.PointAdd(upperCorner, Array(-leftMargin, topMargin, 0))
            'Draw 1 inch scale box
            'helpCorner(0) = Rhino.PointAdd(helpCorner(2), Array(0, 1, 0))
            'helpCorner(1) = Rhino.PointAdd(helpCorner(2), Array(-1, 0, 0))
            'helpCorner(2) = Rhino.PointAdd(helpCorner(2), Array(-1, 1, 0))
        
            'Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(0)), boundaryLines)
            'Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(1)), boundaryLines)
        
            helpCorner(0) = Rhino.pointAdd(upperCorner, Array(pageWidth, 0, 0))
            helpCorner(1) = Rhino.pointAdd(upperCorner, Array(0, -pageHeight, 0))
            helpCorner(2) = Rhino.pointAdd(upperCorner, Array(pageWidth, -pageHeight, 0))
        
            Call Rhino.AddObjectToGroup(Rhino.AddLine(upperCorner, helpCorner(0)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(upperCorner, helpCorner(1)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(0)), boundaryLines)
            Call Rhino.AddObjectToGroup(Rhino.AddLine(helpCorner(2), helpCorner(1)), boundaryLines)
    End Select
    
Rhino.EnableRedraw(True)
End Sub

Rhino.AddAlias "UniversalPrintableArea", "_NoEcho _-RunScript (UniversalPrintableArea)"
You could modify the topMargin, leftMargin, rightMargin, bottomMargin, pageHeight, and pageWidth values to suit your specifications though. I added it as a default script to load on Rhino startup, that way the command is always available to me regardless of what I'm working on.
__________________
Papersmith Forge - Mig
Reply With Quote