Author Topic: Psetup in (Plotconfigs)  (Read 8659 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
Psetup in (Plotconfigs)
« on: March 17, 2008, 02:23:19 PM »
Does anyone know how to get a Page setup into your current layout from another drawing?
In ACAD, it is Psetupin; I am trying to do that via code.
It looks like the method I need is CopyFrom but I am getting a key not found error when setting the Configs.
Once I get that, I will then set the nec layout to the respective page setup (plotconfig)
Any ideas?

Thanks!
Mark

Code: [Select]
Sub Psetupsin()

Dim PltConfig as PlotConfiguration

Set KPltConfigs = ThisDrawing.PlotConfigurations.Item ("I:\Path\Path\Path\Filename-CTB.dwt\K-22x34")
Set HPltConfigs = ThisDrawing.PlotConfigurations.Item ("I:\Path\Path\Path\Filename-CTB.dwt\H-22x34")

  For Each PltConfig In ThisDrawing.PlotConfigurations
   If PltConfig.Name = "K-22x34" Then
    Debug.Print "K"
   Else
    PltConfig.CopyFrom KPltConfigs
   End If
   If PltConfig.Name = "H-22x34" Then
    Debug.Print "H"
   Else
     PltConfig.CopyFrom HPltConfigs
   End If
  Next

End Sub

Guest

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #1 on: March 17, 2008, 02:52:18 PM »
I've got something.... Give me a few minutes to fetch it!

Guest

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #2 on: March 17, 2008, 02:57:11 PM »
Alright.... It uses the CopyObjects of DBX to copy from one file to another.  I use a dialog box, but you can tweak to not use the dialog box.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Psetup in (Plotconfigs)
« Reply #3 on: March 17, 2008, 03:31:07 PM »
Matt, very cool, I will have to look at more in detail later.

ML- Im curious why you would pull one from another dwg when you could just assign what you want from where you are?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ML

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #4 on: March 17, 2008, 05:00:03 PM »

Hey Matt

I downloaded the file but I have not yet had a chance to look at it.
I will definitely look at it tomorrow...thank you

CM,
If you create a drawing called Plotconfigs, you can set up all your pagesetups in that drawing, then in your current drawing (in Paper space) type psetupin,
that will prompt you for a drawing, select your Plotconfigs drawing (or template .dwt) and it will expose all of your pagesetups in that drawing. You can also right click on your layout tab and use The Pagesetup Manager as well to achieve this. Command line is psetupin.

I can give you several reasons why you would do this.

Do you want to set up a plot configuration in every single drawing, or would you rather have one created and import it when needed? In some of my customizations, I will do -layout;
That will give you your options, then you can insert a layout from your Plotconfigs drawing (or .dwt), followed by Psetupin which will allow you to bring in your Plot config as well.

If you do this; you will have all of your plotter configs setup in advance.
So, for instance, say you want to create a new layout; bring in the layout, then the pagesetup (plotconfig) and you are rolling.

Make sense?

Mark

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Psetup in (Plotconfigs)
« Reply #5 on: March 17, 2008, 05:15:21 PM »
yes, but it seems like a lot of extra work.  I do not have any page setups at all.  I setup on the fly thru code, and can save or not save the dwg as I go.  I guess its easier to maintain 1 dvb file on the network than trying to keep up with my users template files.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Bob Wahr

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #6 on: March 17, 2008, 06:27:43 PM »
I did this a while back.  I decided at the time that I didn't want to do it through ObjectDBX.  Then I decided it was easier not to.  Importing from a plotconfig drawing, I would pick through the list of pagestups.  Okay, I want the 11x17, 15x21, 30x42, and 30x42 for PDFs.  So that's four I need to pick from a really long list that we have.  Programtically, I pick the sheet size on a form and it makes the page setups that I want/need.

ML

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #7 on: March 17, 2008, 06:36:30 PM »

CM

Quite the opposite!!!

To me it is a total waste of time to set up your Plotter configs each time.

Listen, try importing  a page setup from a previous drawing next time you are about to do all your settings, then tell me what you think is faster.

Also, what happens when you have more then one plotter or perhaps you are using CTB and STB?

Perhaps for a particular drawing (as Bob eluded to) you only want to use a particular .pc3 file and not all of them?

Well, may be we spoil the users but our routines bring in the pagesetup, then the layout, then every thing else after that.

This also assures that each user has the right settings per plotter and it allows them to do what they are suppose to; that is engineering, not setting up plot config.

To each his own :)

Mark

Bob Wahr

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #8 on: March 17, 2008, 06:39:18 PM »
Mark, I think you're misunderstanding Duh.  He's not saying that you should set them up manually in each drawing that you start.  If you are writing a program which will in part import page setups from another drawing, why not just get your program to create the page setups instead.

ML

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #9 on: March 17, 2008, 06:45:36 PM »

Oh I see his point.
I could certainly do that but if I have a drawing that already contains them then why not just grab them?
Otherwise, I will have a mountain of code for each Plotconfig, it doesn't make much more sense.
Not to mention that "if" the routine is not available, I would like to be able to say to the user
"OK, type psetupin, hit enter and browse to your file, then choose your pagesetup"
I have to think as a  user sometimes

Anyhow, this is all irrelevant. I just want the answer! :) LOL

Mark

Bob Wahr

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #10 on: March 17, 2008, 06:46:47 PM »
Then I'll just shut up since you have it.

ML

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #11 on: March 17, 2008, 06:48:25 PM »

LOL
OK



ML

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #12 on: March 17, 2008, 06:50:14 PM »

Didn't it make sense what I am saying Bob?

Bob, as you know, I always respect your opinion.

It just really doesn't seem to need to be debated, it is fairly cut and dry.

Have a good one!

Mark

Bob Wahr

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #13 on: March 17, 2008, 06:53:51 PM »
Different ways of skinning kittens and all.  My preference is to avoid using external liberries when I can so I would rather have my code make the pagesetups than have it be dependant on DBX to do it.  They'll both get the job done.

ML

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #14 on: March 17, 2008, 06:56:04 PM »

That would be cool if I were doing something on the fly but I want the users to still be able to make changes manually when necessary as well. In this case

Mark

Bob Wahr

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #15 on: March 17, 2008, 07:06:36 PM »
Why would they be any more likely to be able to edit an imported pagesetup, than a pagesetup that was created by VBA, or for that matter, on that was done manually.  After a pagesetup is created, regardless of the method of creation, it can be edited.

ML

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #16 on: March 18, 2008, 09:34:27 AM »

Yes, I actually agree with you Bob; unfortunately the methodology in which we use is not my decision to make.
I am basically told what we need and I then try to get the result.
I did look at code for creating the Plot Configs via code, it looks pretty cut and dry.
After this, I will give that a try. I am sure that it will be a useful methodology to have for other things as well.

Mark

ML

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #17 on: March 18, 2008, 10:22:00 AM »

Matt
I just got to looking at the module you attached.
I really like the way the openfiledia code is laid out; that will certainly be useful.
I still need to look at the psetup part.

You may know this already, but under UserAccounts in Windows, there is also a Common Dia Method

Code: [Select]
Dim objDialog As Variant
 Dim intResult As Variant
 Dim Variable as String
 
'Call FileOpenDialog
 Set objDialog = CreateObject("UserAccounts.CommonDialog")

 objDialog.Filter = "Image File (*.tif)|*.tif|All Files|*.*"
 objDialog.FilterIndex = 1
 objDialog.InitialDir = ThisDrawing.Path
 intResult = objDialog.ShowOpen
 
 If intResult = 0 Then
  Exit Sub
 Else
  Variable = objDialog.FileName
 End If
 

It does not have the extensibility as the openfiledia code in your project but if you only need it for a lousy file, this method works very nice and is "very" short.

Mark

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Psetup in (Plotconfigs)
« Reply #18 on: March 18, 2008, 10:59:23 AM »
ML, I hear what your saying, but it is very hard to beat the speed of clicking 1 button and being done.  The code inside that button is already loaded in memory, as it gets loaded at startup.  I dont have to go find a file to import from, I just set the config I want, and send it to the plotter.  Thats it.  In fact, for some of my users, I purge out all their page setups because they give them weird names, and then cant figure out where their plot went (read which printer).

As you said, to each his own.  If your interested, I'll post my setup code
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ML

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #19 on: March 18, 2008, 11:10:17 AM »

Absolutely CM
Post away man, Post away.

Earlier in this post, Bob eluded to dbx, I wasn't familiar with that, then I saw Matt's code
Sorry Bob!

Code: [Select]
ThisDrawing.Application.GetInterfaceObject("ObjectDBX.AxDbDocument.17")

I did not realize that you had to make a connection to import a lousy Pagesetup.

If you are doing LISP or an ACAD menu macro; you simply do
Menu Macro:  -psetupin;code away;
LISP:  (command "psetupin" "path" "code")

So, this shows that LISP (at times) is better and easier then VBA.

Never thought I would hear myself say that? :)

Yeah, let's see your code CM

Thanks!

Mark

Bob Wahr

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #20 on: March 18, 2008, 11:24:46 AM »
Well crap, I thought you wanted to do it programatically.  If you can do it with Command in lisp, you can do it with thisdrawing.sendcommand in VBA

ML

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #21 on: March 18, 2008, 11:27:42 AM »

Yes, this is true Bob.
I could do that.

I'd still be interested in understanding the way Matt's code is doing it, just for future reference

Mark


Guest

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #22 on: March 18, 2008, 11:43:26 AM »

Yes, this is true Bob.
I could do that.

I'd still be interested in understanding the way Matt's code is doing it, just for future reference

Mark



What I've posted will list all of the page setups in a drawing - helpful if you don't know the name of the page setup you want to import.  But if you already know what you want to import (and it sounds like you do) just use -PSETUPIN behind a button and call it a day.

ML

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #23 on: March 18, 2008, 11:47:52 AM »

Hey Matt

Yep!
That is already done in LISP using a pulldown.

Still, I like The way The FileDia code is situated, that is certainly worth keeping around

Thanks!
Mark

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Psetup in (Plotconfigs)
« Reply #24 on: March 18, 2008, 12:39:25 PM »
the first snippet is what gets called from a button.  I have 3 buttons, 1 for 11x17, 1 for C-Size and 1 for D-Size.  These all make prints using the predefined setups.

the second does just a setup, no plot.

the third is the routine that actually does the work.  It takes arguments from either the first or second snippet and applies as needed.  808 gets credit for helping me with this code.

Code: [Select]
Public Sub Vendor1117()
      Call SetupAndPlot("11x17Draft.pc3", "11X17-CHECKSET.ctb", "ANSI_B_(11.00_x_17.00_Inches)", acScaleToFit, ac90degrees)
      ThisDrawing.Plot.PlotToDevice
      ThisDrawing.Close (True)
End Sub

Public Sub SetupVendor1117()
      Call SetupAndPlot("11x17Draft.pc3", "11X17-CHECKSET.ctb", "ANSI_B_(11.00_x_17.00_Inches)", acScaleToFit, ac90degrees)
End Sub

Public Sub SetupAndPlot(ByRef Plotter As String, CTB As String, SIZE As String, PSCALE As String, ROT As String)
      Dim Layout As AcadLayout
      On Error GoTo Err_Control
      Set Layout = ThisDrawing.ActiveLayout
      Layout.RefreshPlotDeviceInfo
      Layout.ConfigName = Plotter    ' CALL PLOTTER
      Layout.PlotType = acExtents
      Layout.PlotRotation = ROT    ' CALL ROTATION
      Layout.StyleSheet = CTB    ' CALL CTB FILE
      Layout.PlotWithPlotStyles = True
      Layout.PlotViewportBorders = False
      Layout.PlotViewportsFirst = True
      Layout.CanonicalMediaName = SIZE    ' CALL SIZE
      Layout.PaperUnits = acInches
      Layout.StandardScale = PSCALE    'CALL PSCALE
      Layout.ShowPlotStyles = False
      ThisDrawing.Plot.NumberOfCopies = 1

      Layout.CenterPlot = True
      Layout.ScaleLineweights = False
      ThisDrawing.Regen acAllViewports
      ZoomExtents
      Set Layout = Nothing
      ThisDrawing.Save
Exit_Here:
      Exit Sub
Err_Control:
      Select Case Err.Number
            Case "-2145320861"
                  MsgBox "Unable to Save Drawing- " & Err.Description
            Case "-2145386493"
                  MsgBox "Drawing is setup for Named Plot Styles." & (Chr(13)) & (Chr(13)) & "Run CONVERTPSTYLES command", vbCritical, "Change Plot Style"
            Case Else
                  MsgBox "Unknown Error " & Err.Number
      End Select
End Sub
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ML

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #25 on: March 18, 2008, 12:59:07 PM »

Hey CM
Very good!

Yes, I have seen a few examples like this.

Thanks!
Mark

Guest

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #26 on: March 18, 2008, 01:06:11 PM »
the first snippet is what gets called from a button.  I have 3 buttons, 1 for 11x17, 1 for C-Size and 1 for D-Size.  These all make prints using the predefined setups.

the second does just a setup, no plot.

I should set up something like that here for making quick prints/plots.  Thanks for the idea!   :wink:

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Psetup in (Plotconfigs)
« Reply #27 on: March 18, 2008, 01:20:50 PM »
I actually have 6 buttons, 3 for 1 ctb 3 for the other.  All of them pass the arguments to the same setup sub.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ML

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #28 on: March 18, 2008, 01:21:49 PM »
I think it is very cool of course
Still, I like the idea of having a drawing with all my predefined setups, then just importing them in.
Still, I see some good uses for this too

Like I said earlier, to do a pagesetupin is pretty easy with LISP.

CM, are you using all CTB?

We were all CTB here but migrating to STB.

Believe it or not, all my past experience was STB, this is the first environment that I worked in that used CTB.

I definitively prefer STB and styles over color dependent.

Mark

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Psetup in (Plotconfigs)
« Reply #29 on: March 18, 2008, 01:44:50 PM »
Still, I like the idea of having a drawing with all my predefined setups, then just importing them in.
Very valid.  I prefer to maintain 1 dvb instead of a dwg
Like I said earlier, to do a pagesetupin is pretty easy with LISP.
to do it in lisp or use the Command function?  Using command is no better than using ThisDrawing.SendCommand
CM, are you using all CTB?
We were all CTB here but migrating to STB.
Believe it or not, all my past experience was STB, this is the first environment that I worked in that used CTB.
I definitively prefer STB and styles over color dependent.
Once again, to each his own.  Trying to convert to STB after years of CTB is a logistic nightmare.  I dont feel like trying to go down that road with my current group of users.  If I had a few more advanced users, I might give it a go.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ML

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #30 on: March 18, 2008, 01:57:56 PM »

Yes, this is true, using (command "pagesetupin" ) would be the same but understand that it is a very extensive LISP routine and not one I am driving but certainly learning from :)

I feel your pain man. However, we did just that; after years of CTB, we are making the move.
I can not tell you how many drawings I have converted already.

CM, if you decide to go that way, I can certainly help you streamline the process.

You use convertpstyles and all that; you can get all that info in help but I have actually incorporated layer translator into the process as well.

Again, in your business, it may not be that big of a deal but in Civil Design, it is nice to see hydrology on shades of Blue; Landscape on shades of green and so on.

It is an undertaken but with your automation skills, I do believe that you could streamline it.

Mark

Guest

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #31 on: March 18, 2008, 02:09:34 PM »
I'm in the beginning stages of converting the company over to a single CTB file.  We currently use three different ones - one for each department (Civil, Structural, MEP).


Yeah... that'll be fun.  :|

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Psetup in (Plotconfigs)
« Reply #32 on: March 18, 2008, 02:52:18 PM »
Actually it wont be that hard.  Pick shades of colors for the layers, and your users probably wont even notice.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Psetup in (Plotconfigs)
« Reply #33 on: March 18, 2008, 02:52:56 PM »
for instance, all your Blue Mech layers are now color 160, all your red Civil layers are 11 and so on.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

ML

  • Guest
Re: Psetup in (Plotconfigs)
« Reply #34 on: March 20, 2008, 10:42:05 AM »

I am definitely an STB guy
If you can select what colors you want layers to be, independently of lineweights; that is a no brainer, to me at least.

It sucks that I have to use all red to make my drawing plot at the thinnest lineweights.

If I have a layer that has hydrology of some sort, the layer is going to be blue; then with the style, I make the lineweight thickness whatever it needs to be.

We do this though; for existing it will be a lighter shade of blue on a thinner lineweight then proposed, so you can still have contrast between existing and proposed.

It is really not that bad to convert; I would be glad to help out.

To start, just make a copy of your ctb file and type convertpstyles at the command line.

The bigger struggle is to get the users out of the red, yellow, green, cyan, magenta specific world.

Mark