Changing Orientation and Size of a Titleblock Template in Pa
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Changing Orientation and Size of a Titleblock Template in Pa

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
matt_1ca
Guest





Posted: Fri Mar 18, 2005 10:01 am    Post subject: Changing Orientation and Size of a Titleblock Template in Pa Reply with quote

Does anyone know how I can change the orientation of a titleblock template in paperspace layouts using VB?

I have created a program the works in paperspace -- it creates layouts and inserts titleblocks in them which gets populated with information that I extract from my modelspace drawing.

So far I have been successful in it -- but the only thing standing in the way is the size and orientation of the paper --

I will need to be able to control both of it through code -- to really succeed and I do not know how to do it.

Manually, what I am describing can be accomplished by right clicking the paperspace layout tab thence clicking page setup of the popup menu and choosing say for example
8.5" x 14" and portrait for drawing orientation.

So far I have had no luck trying to figure this one out -- the closest thing I've got seems to be GetPaperSize for retrieving dimensions but how about setting them -- and then changing the orientation from say landscape to portrait and vise versa -- is it possible?

Thank you so much for all the kind help you can give.

Matt

Back to top
matt_1ca
Guest





Posted: Fri Mar 18, 2005 4:09 pm    Post subject: Re: Changing Orientation and Size of a Titleblock Template i Reply with quote

The kind of code that I call with sendcommand from VB is shown below:

(defun TitleblockInsert(strInblock)
(setq inblock strinblock)
(setq clay (getvar "clayer"))
(setq osmode (getvar "osmode"))
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(setvar "attreq" 0)
(command "expert" 1)
(setq iopset strinblock)
(command "layout" "n" iopset)
(command "layout" "s" iopset)
(setq layall (ssget "x" '((0 . "VIEWPORT"))))
(command "erase" layall "")
(setq blkinspt (list 0 0 0))
(setq MviewsW (list (car blkinspt) (+ (cadr blkinspt) 94)))
(setq Mviewne (list (+ (car blkinspt) 203) (+ (cadr blkinspt) 291)))
(setvar "clayer" "defpoints")
(command "mview" Mviewsw Mviewne)
(command "expert" 0)
(setq inspt (list 0 0 0))
(setq iopnum iopset)
(setq blkinspt (list 0 0 0))
(setq view1se (list (+ (car blkinspt) (* 203.4 1)) (- (cadr blkinspt) (* 0.4 1))))
(setq view1nw (list (- (car view1se) (* 203.8 1)) (+ (cadr view1se) (* 343.8 1))))
(command "-view" "w" iopno view1se view1nw)

(if (= inblock "mytitleblock-1")
(progn
(command "-insert" "mytitleblock-1" inspt "" "" ""

)
)
)



(if (= inblock "mytitleblock-2")
(progn
(command "-insert" "mytitleblock-2" inspt "" "" ""
)
)
)


(if (= inblock "mytitleblock-3")
(progn
(command "-insert" "mytitleblock-3" inspt "" "" ""
)
)
)




(if (= inblock "mytitleblock-4")
(progn
(command "-insert" "mytitleblock-4" inspt "" "" ""

)
)
)

(setvar "attreq" 1)

)

It does what I want it -- inserts the titleblock that I want into a layout in paperspace.

In the example code shown above it will insert a portrait type of titleblock -- when this portrait 8.5" x 14" gets inserted into a landscape of a different size then I start getting problems and hence my need to manipulate layout size and orientation.

Thank you so much for all the kind help you can give.

Matt
Back to top
Jackrabbit
Guest





Posted: Fri Mar 18, 2005 6:25 pm    Post subject: Re: Changing Orientation and Size of a Titleblock Template i Reply with quote

From AutoCAD Help...

[pre]

To set the paper size, use the CanonicalMediaName property.


--------------------------------------------------------------------------------
CanonicalMediaName Property

Specifies the paper size by name.

Signature

object.CanonicalMediaName

object

Layout, PlotConfiguration
The object or objects this property applies to.

CanonicalMediaName

String; read-write
The name of the paper size.

Remarks

Changes to this property will not be visible until after a regeneration of
the drawing. Use the Regen method to regenerate the drawing.
[/pre]

Back to top
matt_1ca
Guest





Posted: Fri Mar 18, 2005 9:36 pm    Post subject: Re: Changing Orientation and Size of a Titleblock Template i Reply with quote

Hello and thank you for your answer -

I did see this method before and was thinking it might be the possible solution -- but I figured maybe I'd like to hear what people would say -- so as soon as I got your answer I tried it out right away and it worked like magic for changing the size of the paper that is -- like for example when a paper is oriented landscape and has Envelope size and I change it to Legal -- it does exactly that -- unfortunately -- the method does not change the orientation of the paper to legal size portrait so it did solve one of the two problems but left the other one (changing orientation) unsolved.

Thanks again,
Matt
Back to top
matt_1ca
Guest





Posted: Fri Mar 18, 2005 9:45 pm    Post subject: Re: Changing Orientation and Size of a Titleblock Template i Reply with quote

Its okay everybody -- please consider this question closed -- I figured out how to rotate orientation of the layout and it is
layout.plotrotation --

Thanks again,
Matt
Back to top
Mike Tuersley
Guest





Posted: Fri Mar 18, 2005 10:06 pm    Post subject: Re: Changing Orientation and Size of a Titleblock Template i Reply with quote

Hate to burst your bubble, but that is not reliable.

What you need to do is retrieve the height/width of the current device's
paper size and the layout's size [extmin/extmax] and comapring the two to
calculate whether to rotate or not. For instance, if the layout is
portrait, but the printer's paper is landscape, your rotate will over
rotate it.

-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB