Author Topic: load certain files in startup suite based on profile  (Read 6222 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
load certain files in startup suite based on profile
« on: January 10, 2008, 10:49:21 AM »
We have 2 different profiles with the main difference being the printer configurations. I have taken some code that i had in our acad.lsp and and created 2 seperate lisp files which will load page setups from different dwt files. I am having to add the appropriate lisp file to the startup suite depending on which profile is loaded. I'm wondering if there is a way I can automate this process?

Guest

  • Guest
Re: load certain files in startup suite based on profile
« Reply #1 on: January 10, 2008, 10:52:48 AM »
Why not just load it from the ACAD.lsp file instead, depending on what profile name is active?

ELOQUINTET

  • Guest
Re: load certain files in startup suite based on profile
« Reply #2 on: January 10, 2008, 10:57:31 AM »
yes i suppose it could be done from that end as well. the lisp is below and the only difference between this one and the other is the dwt it loads from. i would need to see which profile is active then load the page setups from the corresponding dwt. How would i modify this to make that happen? Thanks Matt

Code: [Select]
;;  Function to delete all user plot set ups then load page setups from page-setups.dwt
(defun c:Del_Pagesetups (/ curdwg pslayout x)
 (vl-load-com)
 (setq
   curdwg   (vla-get-ActiveDocument (vlax-get-Acad-Object))
   pslayout (vla-get-Layout (vla-get-PaperSpace curdwg))
 ) ;_ end of setq
 ;; Call RefreshPlotDeviceInfo before GetPlotDeviceNames
 (vla-RefreshPlotDeviceInfo pslayout)
 (vlax-for x (vla-get-Plotconfigurations curdwg)
   (vla-delete x)
 ) ;_ end of vlax-for
)               ; End Plot_config_list
(c:Del_Pagesetups)

(command ".-psetupin" "PAGE-SETUPS.DWT" "*")

(defun c:change_page_setups (/ *adoc*      *adoc*
     *layouts* page_setups dcl_id
     userclick selection   plotcfg
     clay
    )
;;;
  (defun get_page_setup (doc func / lst)
    (vlax-map-collection
      (vla-get-plotconfigurations doc)
      '(lambda (x) (setq lst (cons ((eval func) x) lst)))
    )
    (reverse lst)
  )
;;;
  (defun getSelectedItems (tilename AllItemsList / indexes)
    (if (setq indexes (get_tile tilename))
      (setq indexes (read (strcat "(" indexes ")"))
    indexes (mapcar '(lambda (n) (nth n AllItemsList))
    indexes
    )
      )
    )
    indexes
  )
;;;
  (setq *acad* (vlax-get-acad-object))
  (setq *adoc* (vla-get-activedocument *acad*))
  (setq *layouts* (vla-get-layouts *adoc*))
  (vl-load-com)
  (defun on_list_pick ()
    (if (= (get_tile "page_setup_names") "")
      (mode_tile "select" 1)
      (mode_tile "select" 0)
    )
  )
  (and
    (setq page_setups (get_page_setup *adoc* 'vla-get-name))
    (setq dcl_id (load_dialog "page_setups.dcl"))
    (new_dialog "page_setup" dcl_id)
    (start_list "page_setup_names")
    (mapcar 'add_list page_setups)
    (not (end_list))
    (action_tile "cancel" "(done_dialog 0)")
    (action_tile
      "select"
      (strcat
"(setq selection (getSelectedItems \"page_setup_names\" page_setups))"
"(done_dialog 1)"
      )
    )
    (action_tile "page_setup_names" "(on_list_pick)")
    (not (mode_tile "select" 1))
    (setq userclick (start_dialog))
  )
  (if dcl_id
    (unload_dialog dcl_id)
  )
  (if (and userclick selection)
    (and
      (setq plotcfg (vla-item (vla-get-plotconfigurations *adoc*)
      (car selection)
    )
      )
      (vlax-map-collection
*layouts*
'(lambda (x)
   (if (eq (vla-get-modeltype x) :vlax-false)
     (vla-copyfrom x plotcfg)
   )
)
      )
    )
  )
  (princ)
)
« Last Edit: January 10, 2008, 11:06:17 AM by Eloquintet »

Guest

  • Guest
Re: load certain files in startup suite based on profile
« Reply #3 on: January 10, 2008, 11:24:25 AM »
(alert (getvar "cprofile"))  will tell you what the current profile name is.

ELOQUINTET

  • Guest
Re: load certain files in startup suite based on profile
« Reply #4 on: January 10, 2008, 11:49:13 AM »
yes i know how to get the current profile but don't need to alert the user. i need to load page setups from a dwt based on which is current.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: load certain files in startup suite based on profile
« Reply #5 on: January 10, 2008, 11:58:39 AM »
yes i know how to get the current profile but don't need to alert the user. i need to load page setups from a dwt based on which is current.

Code: [Select]
(defun instemp (/ pro)
  (setq pro (strcase (getvar 'cprofile)))
  (cond ((= pro "TEMP1")
;;do stuff
)
((= pro "TEMP2")
;;do stuff
)
((= pro "TEMP2")
;;do stuff
)
  )
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pmvliet

  • Guest
Re: load certain files in startup suite based on profile
« Reply #6 on: January 10, 2008, 01:40:22 PM »
You say you are switching profiles for printer configurations. May I ask what you are changing
that is unique? Or why you need 2 different profiles?

The reason I am asking is you are changing profiles which then causes you to change printing characteristics.
In your case, you have 2 of each and  1 of each go together if I am following you correctly.

I'm just thinking, you can make the profile change and printing preference change in one lisp routine
and only have 1 profile for your users.

If you don't want to consider that, the suggestion by ronjonp would work.
Or if your different profiles had a menu (could be hidden) you could put it in
that menu.mnl file.

Pieter

ELOQUINTET

  • Guest
Re: load certain files in startup suite based on profile
« Reply #7 on: January 10, 2008, 02:39:47 PM »
OK here is the scenario that i have. i have some drafters in my department and i have some more drafters in another department. when we want to print an 8x11 drawing we choose a pagesetup which will send it to this printer and when they choose the same page setup it goes to another printer. i initially created different pc3 files for them and gave them a different mapping for pc3 files in options. i nitially just had one profile and just manually changed this path when installing. The problem I was encountering was that if a user selects a pagesetup that uses a pc3 file which looks for a plotter they don't have installed it tells them they need to update the pc3 file. this dialogue box does not allow the user to cancel out so most users just select another printer which in turn screws up the pc3 for the people who have that printer installed. the quick fix would be to have everyone that does cad connected to all of the possible printers but the other people are in a different workgroup and the IT guys claim that they don't have time to install a printer that the user will not be using and don't want to allow me to do it either. To avoid this conflict i wanted to setup two profiles, template files with pagesetups in them and 2 folders with different pc3 files. I don't want the user to have the option so select screw it up on any level. Does this make sense now?

ELOQUINTET

  • Guest
Re: load certain files in startup suite based on profile
« Reply #8 on: January 10, 2008, 02:41:43 PM »
Ron,

I tried to implement your idea and put the code back in our acad.lsp but it is not loading any pagesetups?

Code: [Select]
(defun loadfromdwt (/ pro)
  (setq pro (strcase (getvar 'cprofile)))
  (cond ((= pro "Mechoshade Standard")
(command ".-psetupin" "PAGE-SETUPS.DWT" "*")
)
((= pro "Mechoshade Standard PM")
(command ".-psetupin" "PAGE-SETUPS PM.DWT" "*")
)
  )
)

ronjonp

  • Needs a day job
  • Posts: 7531
Re: load certain files in startup suite based on profile
« Reply #9 on: January 10, 2008, 02:49:57 PM »
The strcase is looking for an all caps string to match to.

Try this....it will remove all pagesetups before trying to import so it won't stall when a duplicate is encountered.

Code: [Select]
(defun loadfromdwt (/ pro pc)
  (setq pro (getvar 'cprofile)
pc  (vla-get-Plotconfigurations
      (vla-get-ActiveDocument
(vlax-get-Acad-Object)
      )
    )
  )
  (cond ((= pro "Mechoshade Standard")
(vlax-map-collection pc 'vla-delete)
(command ".-psetupin" "PAGE-SETUPS.DWT" "*")
)
((= pro "Mechoshade Standard PM")
(vlax-map-collection pc 'vla-delete)
(command ".-psetupin" "PAGE-SETUPS PM.DWT" "*")
)
  )
  (princ)
)
« Last Edit: January 10, 2008, 02:56:42 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pmvliet

  • Guest
Re: load certain files in startup suite based on profile
« Reply #10 on: January 10, 2008, 04:09:49 PM »
Instead of loading files based on profile, why don't you have it change based on who they are or as you state they are in a different workgroups?? If they are in "your workgroup" load this and if they are in "that workgroup" load that.
Why involve multiple profiles if you don't need to... I apologize if I'm missing something totally obvious

Another option would be to implement a different plotting system that it automated such like MP is working on:
http://www.theswamp.org/index.php?topic=20741.msg

I developed something similar using scripts and a plotting pull-down menu.
If the user wanted to print 11x17 to the printer next to them, they selected it.
If they then wanted an 11x17 to print across the hall, they selected that option.
Everything is behind the scenes and I did not keep page setups in each individual file.

I guess that is getting away from what you desire, but I'm just trying to look at it from
a different perspective.

Pieter


ELOQUINTET

  • Guest
Re: load certain files in startup suite based on profile
« Reply #11 on: January 10, 2008, 04:39:35 PM »
ron the complete routine deletes all page setups prior to loading specified new ones (see full code at the beginning). So you are saying all I need to do is capitalize the profile names and strcase should work fine? I will test this out myself. Pieter I understand what you mean but I think in my environment this method is the easiest to use. We have people moving back and forth between these 2 workgroups (don't ask) so it's easiest to load a different profile if they move and off to work they go. Thanks for your input though

ronjonp

  • Needs a day job
  • Posts: 7531
Re: load certain files in startup suite based on profile
« Reply #12 on: January 10, 2008, 04:48:23 PM »
I would do it like pmvliet....right now I check the IP addresses (same domain, two different logon servers) to determine which pagesetups need to be loaded and what shared printers need to be pointed to.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ELOQUINTET

  • Guest
Re: load certain files in startup suite based on profile
« Reply #13 on: January 10, 2008, 04:56:10 PM »
well i tried to put the profile names in caps and even eliminate spaces and it doesn't load any page setups. I would really prefer not to have to go to that deep of a level because when I start probing that deeply in our network configuration the IT guys get defensive and elude my questions. This is why I'd prefer to not have to have it based on network info but autocad profile that way i am in control of the variables.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: load certain files in startup suite based on profile
« Reply #14 on: January 10, 2008, 05:01:49 PM »
Did you try my last solution?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC