DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Improved Print Rectangle, uses print Dialog, works in 3d

Started by bdeck, January 24, 2007, 03:09:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bdeck

Here's an improved print rectangle macro, that allows scaled print or print to fit page, using the print dialog.

Shortcomings of this macro:
   a) It will not print images unless they fall completely within the section rectangle.
   b) Print preview causes a nonfatal premature end to the macro. Dont use it.

Thanks to janders, Lar, Prl, and RobS.

BD


' pr5.d3m     brent deck   1/07
' Macro to print contents of a section rectangle to scale or to fit page
' Print dialog works, but print preview fails.
' Based on a combination of methods suggested by janders and Lar.
' Does not print images unless totally enclosed by section rectangle.


if sys(1)>2 then  'no of pts set'
     message "too many points"
     end
endif      

>SectionCopy
{
     <UsePresetPoints
     <Maxpoints 2
     <CmdPrompt "Set 2 points to define print rectangle"
     <Incomplete 1      
}

sys(49) = 1  'Disable cursor move on POINTXYZ    
sys(36) = 1  'silent mode    fails to hide dialog

' *****  these lines get parent printer settings for 'print to scale' (optional)
sys10=sys(10)        
sys11=sys(11)
sys1114=sys(1114)
sys32=sys(32)
sys134=sys(134)    ' margins
sys135=sys(135)
sys136=sys(136)
sys137=sys(137)
' ******************   (print orientation does not seem to be gettable)


>New  ' create a new temporary drawing
{
}


>Paste    ' paste a copy of selected section into new temp drawing
{
<Type 1          ' 1 = Fixed scale (always paste at original size)
' <Pointxyz [0,0,0]   ' 3d seems to work better without this parameter, dunno why
}

>ID_ZOOM_SELECTION   ' zoom to pasted selection (optional)
{
}

>Deselect          '  (optional)
{
}


' ****************   use parent printer settings for "print to scale"   (optional)
sys(10)=sys10    
sys(1114)=sys1114
sys(32)=sys32
sys(134)=sys134    ' margins
sys(135)=sys135
sys(136)=sys136
sys(137)=sys137
sys(11)=sys11       ' use this line to default to parent's scale factor
sys(11)=0             ' or use this line to default to "fit to page"
'***********************************************

>Print   ' show print dialog
{
}

>Close    ' close the temporary drawing
{
<SaveChanges 0
}
 
sys(1)=0
end

Rob S

Good man, this works just fine for me.

Maybe the Troll will be lookin' to hire you!! (or maybe eliminate the competition?)

I don't know why preview fails, that is too bad.

It must do something to break running macro code by opening a new window.

Amazing what you can make a program do, with a good macro interface.
User since forever

prl

Nice, the other day I ventured into paper space trying to create a process that I had hoped would automatically create (and destroy) a paper space layout "on the fly" for just such quick print purposes. It was intended to eliminate the drudgery and hassle of creating a layout,  creating a view frame (to some scale) and the dreaded centering problem we have with paper space.

Later I found out I was poking myself in the eye.  Non-rectangular view frames aren't recognized as view frame entities by OLE. Seems the only way I can get it to work is to use Lar's extent box concept.

As Dt would say (maybe), "the paper space code base needs some loving".