Author Topic: New Layout creation issue  (Read 3829 times)

0 Members and 1 Guest are viewing this topic.

KewlToyZ

  • Guest
New Layout creation issue
« on: May 03, 2012, 03:18:39 PM »
I'm trying to automate layout creation with previous routines but I am running into an issue in 2013.
It seems to predetermine if there is a layout with that name already in the drawing and auto increments the name of the layout for the user now. I was wondering where that "new" auto incremented name is stored to capture it so it doesn't grab and rename the pre-existing layout. Or if I am going to have to check for that layout name before running the template layout creation and rename the pre-existing layout before running the new one?

Also, is it safe to save a 2013 dwt file down as a 2007 dwg file then change the extension to be compatible with older versions? DWT doesn't have versions when saved so that is what I usually do, but I was curious if anyone had issues with it?

KewlToyZ

  • Guest
Re: New Layout creation issue
« Reply #1 on: May 03, 2012, 03:35:19 PM »
I think I am going to have to re-write and create a placeholder name for new layouts, then set focus to the placeholder name, do my template import setup settings and rename it afterwards.

KewlToyZ

  • Guest
Re: New Layout creation issue
« Reply #2 on: May 03, 2012, 03:52:11 PM »
Hmmm I would have to delete the viewport on the layout created from new to continue the routine...
This is looking like a road block to adding sheets with routines.

KewlToyZ

  • Guest
Re: New Layout creation issue
« Reply #3 on: May 03, 2012, 04:25:36 PM »
ok I got my pattern, cludgy but ok for now:

Get Sheet name & size info

Layout
New
SHTX-1

Layout
Set
SHTX-1

Erase
All
" "

Layout
Rename
SHTX-1
"Place Holder Text"

Pagesetup routine

VPORT routine

KewlToyZ

  • Guest
Re: New Layout creation issue
« Reply #4 on: May 03, 2012, 04:49:22 PM »
 :ugly: Derp

KewlToyZ

  • Guest
Re: New Layout creation issue
« Reply #5 on: May 03, 2012, 04:56:18 PM »
Can someone throw me a bone where to check that "Create viewport in new layouts" toggle is under ?

KewlToyZ

  • Guest
Re: New Layout creation issue
« Reply #6 on: May 03, 2012, 05:04:33 PM »
Funny I did not know 2013 was code named Jaws.... lol!

Lee Mac

  • Seagull
  • Posts: 12711
  • London, England
Re: New Layout creation issue
« Reply #7 on: May 03, 2012, 05:37:42 PM »
Can someone throw me a bone where to check that "Create viewport in new layouts" toggle is under ?

Code - Auto/Visual Lisp: [Select]
  1.         (vla-get-preferences
  2.             (vlax-get-acad-object)
  3.         )
  4.     )
  5. )

Tharwat

  • Swamp Rat
  • Posts: 684
  • Hypersensitive
Re: New Layout creation issue
« Reply #8 on: May 03, 2012, 05:39:59 PM »
Can someone throw me a bone where to check that "Create viewport in new layouts" toggle is under ?

Check this out ...
Code - Auto/Visual Lisp: [Select]
  1. (setenv "CreateViewports" "0")

KewlToyZ

  • Guest
Re: New Layout creation issue
« Reply #9 on: May 03, 2012, 09:51:50 PM »
Thanks gents.
I have been away a while and I was barely getting the hang of code when I went on hiatus.
Trying to dive into the deep end again. It's like learning a foreign language, if I don't use it, not much stays with me.
Since the new layout creation in 2013 prevented me from using my templates as easily as before, I knew vla would be my best bet setting the current layouts pagesetup after psetupin.
I have been reading posts from many of you gents on a few other forums too. Cadalyst won't even let me log in to get code to look at CAB's stuff anymore lol.

KewlToyZ

  • Guest
Re: New Layout creation issue
« Reply #10 on: May 04, 2012, 12:28:02 AM »
Can someone throw me a bone where to check that "Create viewport in new layouts" toggle is under ?

Check this out ...
Code - Auto/Visual Lisp: [Select]
  1. (setenv "CreateViewports" "0")

Where do you find these environment bit codes?
Can I list them like sysvdlg?
...
nevermind, I googled:
http://www.cadtutor.net/forum/archive/index.php/t-61283.html?s=23e7623a39a659048fc07be3623e41df
Thanks =)
« Last Edit: May 04, 2012, 12:40:00 AM by KewlToyZ »

KewlToyZ

  • Guest
Re: New Layout creation issue
« Reply #11 on: May 04, 2012, 01:27:45 AM »
This bit by Lee Mac :http://www.cadtutor.net/forum/archive/index.php/t-44234.html

Got my attention. I still get lost in vla, but it is so much faster and more elegant.
I'm gonna have to hit the books this weekend and see if I can get my head around it better.

I got my current routine workaround from code here and other locations up and running.
But if I get my head into this better I bet it could be a lot more stable and much more elegant.

I think between learning just vla and dcl better I would be much happier than trying to work in dotnet.
Just much less overhead, and I have never been able to keep my workstations stable enough mixing dotnet and AutoCAD. I always end up with framework installation conflicts confusing me as errors in VS or Autodesk. It drove me batty just doing web dev with VS & SQL while doing AutoCAD management. I needed two separate machines. Tehn we started testing Vista & Windows 7 with XP ... made my head hurt  :ugly:

Tharwat

  • Swamp Rat
  • Posts: 684
  • Hypersensitive
Re: New Layout creation issue
« Reply #12 on: May 04, 2012, 04:19:30 AM »
Can someone throw me a bone where to check that "Create viewport in new layouts" toggle is under ?

Check this out ...
Code - Auto/Visual Lisp: [Select]
  1. (setenv "CreateViewports" "0")

Where do you find these environment bit codes?
Can I list them like sysvdlg?
...
nevermind, I googled:
http://www.cadtutor.net/forum/archive/index.php/t-61283.html?s=23e7623a39a659048fc07be3623e41df
Thanks =)

Hi

Here is a list of functions from Afralisp ...

http://www.afralisp.net/archive/lisp/enviro.htm

Lee Mac

  • Seagull
  • Posts: 12711
  • London, England
Re: New Layout creation issue
« Reply #13 on: May 04, 2012, 07:25:20 AM »
As a general rule, most of the settings in the 'Options' dialog can be found in properties derived from the VLA Preferences Object and VLA Database Preferences Object; those which are drawing dependent will be stored in properties derived from the Database Preferences Object accessed from the Document Object, whereas persistent settings will be stored in properties derived from the Preferences Object accessed from the Application Object. The settings stored by the Preferences Object are also found in the registry (as environmental variables), but the Preferences Object provides a safer, user-friendly interface for retrieving and changing these settings, rather than 'blindly' changing registry values, since the functions have restricted parameters.


KewlToyZ

  • Guest
Re: New Layout creation issue
« Reply #14 on: May 04, 2012, 11:26:57 AM »
As a general rule, most of the settings in the 'Options' dialog can be found in properties derived from the VLA Preferences Object and VLA Database Preferences Object; those which are drawing dependent will be stored in properties derived from the Database Preferences Object accessed from the Document Object, whereas persistent settings will be stored in properties derived from the Preferences Object accessed from the Application Object. The settings stored by the Preferences Object are also found in the registry (as environmental variables), but the Preferences Object provides a safer, user-friendly interface for retrieving and changing these settings, rather than 'blindly' changing registry values, since the functions have restricted parameters.

Thanks Lee!
VLA Preferences Object - Application Object:
Interface toggles & environment settings

VLA Database Preferences Object - Document Object
Drawing settings & objects/entities contained within

I agree running reg files is horrible and I never liked relying completely on shortcuts running /p "X:\Folder\Settings\profile.arg" alone. The problem is that is the only means of controlling things like Tool Palettes.
Tharwat gave me the easiest route to maintain a predictable environment for troubleshooting over the phone and project standardization.

The vl code with dcl gives me an environment with tools I like to use:
TextPad and every once in awhile the vlide for debugging.

I was reading through this stuff Lee wrote here:
http://www.cadtutor.net/forum/archive/index.php/t-44234.html
Code: [Select]
(defun NewLay (lay)
(vl-load-com)

(setq *adoc* (cond (*adoc*) ((vla-get-ActiveDocument
(vlax-get-acad-object)))))

(if (vl-catch-all-error-p
(setq lay (vl-catch-all-apply (function vla-add)
(list (vla-get-layouts *adoc*) lay))))

(vl-catch-all-error-message lay) lay))

Code: [Select]
;; lay = New Layout Name (Will be Created if non-existent)
;; (CopytoLayout "New Layout)

(defun CopytoLayout (lay / ss NewLay ObjLst)
(vl-load-com)
; Lee Mac ~ 27.01.10

(setq *acad* (cond (*acad*) ((vlax-get-acad-object)))
*adoc* (cond (*adoc*) ((vla-get-ActiveDocument *acad*))))

(cond ( (not (snvalid lay)))

( (ssget)

(vlax-for obj (setq ss (vla-get-ActiveSelectionSet *adoc*))
(setq ObjLst (cons Obj ObjLst)))
(vla-delete ss)

(if (vl-catch-all-error-p
(setq NewLay (vl-catch-all-apply
(function vla-item)
(list (vla-get-Layouts *adoc*) lay))))

(setq NewLay (vla-Add (vla-get-Layouts *adoc*) lay)))

(vla-CopyObjects *adoc*

(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray vlax-vbObject
(cons 0 (1- (length ObjLst))))

(reverse ObjLst)))

(vla-get-Block NewLay)))))
nopasaran

I'm going to read through some Vlisp books this weekend so I can actually write in the pseudo code to identify things in those routines to make sure I am actually fishing instead of asking for fish   ;-)

This group helped me out for years, I just don't want to treat it like a crutch.

What I got assembled is a mutt right now:

Code: [Select]
(command "Layout" "New" "SHTX-1")
;;; Ed Jobe
;;; Sets a Layout to a PlotConfiguration object by
;;; passing a string representing the name of
;;; the Page Setup.
;;; Usage: (SetPlotConfig "PlotConfig_name")
(vl-load-com)
(defun SetPlotConfig (pcname / PlCfg ThisDwg AcadApp)
  (setq AcadApp    (vlax-get-acad-object)
ThisDwg    (vla-get-activedocument AcadApp)
ThisLayout (vla-get-activelayout ThisDwg)
;; Get a valid PlotConfiguration object if it exists
PlCfg    (vl-catch-all-apply
     'vla-item
     (list
       (vla-get-PlotConfigurations
ThisDwg
       )
       pcname
     )
   )
  )
  (if (not (vl-catch-all-error-p plcfg))
    (vla-copyfrom ThisLayout PlCfg)
  )
)


;============================New Approach============================

((= shtsz "11x17")
(setq mySht "11x17-")
(setq mySuffix (getstring "\nEnter new layout description: (Example: 11x17-YourTitle) : 11x17-"))
(setq shtnm (strcat mySht mySuffix))
(command "expert" "2")
(command "Layout" "ReName" "SHTX-1" shtnm)
(command "Layout" "Set" shtnm)
(command "psetupin" "11x17-AMEP.dwt" "PDF 11x17")
(SetPlotConfig "PDF 11x17")
(command "regen")
(command "Zoom" "Extents")
(command "expert" "0")
(getNewBorder)
(oneWindow)
(command "TILEMODE" "1")
(delOldSetups)
)
;================================Old Approach==============================
((= shtsz "12x18")
(setq mySht "12x18-")
(setq mySuffix (getstring "\nEnter new layout description: (Example: 12x18-YourTitle) : 12x18-"))
(setq shtnm (strcat mySht mySuffix))
(command "expert" "2")
(command "layout" "t" "12x18-AMEP.dwt")
(command "12x18")
(command "layout" "rename" "12x18" shtnm)
(command "layout" "s" shtnm)
(command "psetupin" "12x18-AMEP.dwt" "PDF 12x18")
(command "expert" "0")
(getNewBorder)
(oneWindow)
(command "TILEMODE" "1")
(delOldSetups)
)
;================================================


I don't see this as clean or predictable yet.

KewlToyZ

  • Guest
Re: New Layout creation issue
« Reply #15 on: May 04, 2012, 01:38:39 PM »
Wow, it's been 6 years since this thing started....
http://www.theswamp.org/index.php?topic=9928.msg127505#msg127505

I got this working, it punches through fast.
But I am going to see what I can create based on Lee Mac's examples.

I use a lot of keyboard when i run AutoCAD so I have some other routines mixed in.

After this I switch the vb over to DCL