Jump to content

Recommended Posts

Posted

I got a script to set automatic toolpalettes profiles but it doesn't work :S

I gives this warning:

; error: Automation Error. Description was not provided.

got the code from here

http://forums.autodesk.com/t5/CAD-Managers/Populating-Tool-Palette-Changes-Across-Network/m-p/2855520

this is the code

(defun c:profileset () 
(vl-load-com)
(setq fso (vlax-create-object "Scripting.FilesystemObject")) ;create ability to access windows file folders
(setvar "ACADLspAsDoc" 0)
(setq acadprofile (vla-get-profiles (vla-get-preferences (vlax-get-acad-object))))
(setq actprofile (strcase (vla-get-activeprofile acadprofile)))
;Create empty temporary profile and save on network - call it Temp
(vlax-invoke-method acadprofile 'ImportProfile "Temp" "I:\\Engineering\\CAD Support files\\Tool palettes\\temp.arg" :vlax-true) ;create temp profile to be imported or designate existing profile
(vla-put-ActiveProfile acadProfile "Temp") ;switch to temp profile
(setq iawspath (strcat "I:\\Engineering\\CAD Support files\\Tool palettes")) ;<- modify for path and name of network AWS file
(setq copy_path (strcat (getvar "ROAMABLEROOTPREFIX") "Support\\Profiles\\" actprofile "\\Profile.aws"))
(vlax-invoke-method fso 'CopyFile iawspath copy_path :vlax-true)
(vlax-invoke-method fso 'CopyFile copy_path (strcat Acad_Local_Root "\\User Profiles\\" actprofile "_Profile.aws") :vlax-true)
(vla-put-activeprofile acadprofile actprofile) ;set profile as active
(vla-deleteprofile (vla-get-profiles (vla-get-preferences (vlax-get-acad-object))) "Temp")
;release vla/x function calls and set variables to 'nil'
(vlax-release-object fso) (setq fso nil)
(vlax-release-object acadprofile) (setq acadprofile nil)
(setvar "cmdecho" 0)
(setvar "nomutt" 0)
;(gc) ;garbage collection
)

I have no idea where and how to look for the error. Since i am not really good in visual lisp.

Posted

I use this to set the current tool palette paths:

(setq *files* (vla-get-files (vla-get-preferences (vlax-get-acad-object))))
(setq ToolPalettePath (vlax-get-property *files* "ToolPalettePath"))
(setq    path1     (strcat "Y:\\ToolPalette"
            (itoa ccadversion)
            " (Eng)"
            ";"
            "Y:\\ToolPalette"
            (itoa ccadversion)
            " (EP)"
            ";"
            "Y:\\ToolPalette"
            (itoa ccadversion)
            " (Surv)"
        ) ;_ end of strcat
 ) ;_ end of setq
(if (/= (wcmatch ToolPalettePath (strcat "*" "ToolPalette" (itoa ccadversion) " (Eng)" "*")) t)
   (setq ToolPalette (strcat path1 ";" ToolPalettePath))
   (setq ToolPalette ToolPalettePath)
 ) ;end if
(vla-put-ToolPalettePath *files* Toolpalette)
; Release the object
 (vlax-release-object *files*)
 (princ)

ccadversion is just the version number of autocad, obtained by:

ccadversion      (atoi (substr (ver) 13))

Posted

I fixed it!!!!

It now sets the correct tool palettes path and replaces the aws file in the profile directory with one from the network! It is awesome.

It also convert the profile name from > to VANILLA which is the directory name. (autocad default profile name adds >)

(defun c:aws (/ acadprofiles copy_path fso)
(vl-load-com)
(command "*_TOOLPALETTEPATH" "I:\\Engineering\\CAD Support files\\Tool palettes")
(setq acadprofiles (vla-get-profiles (vla-get-preferences (vlax-get-Acad-Object))))
 (setq actprofile (vla-get-ActiveProfile acadprofiles))
 ;(princ actprofile)
(vlax-invoke-method acadprofiles 'ImportProfile "Temp" "I:\\Engineering\\CAD Support files\\Profiles\\Temp.arg" :vlax-true) ;create temp profile to be imported or designate existing profile
(vla-put-ActiveProfile acadProfiles "temp") ;switch to temp profile
(setq actprofile3 (vl-string-trim "<" actprofile))
(setq actprofile2 (vl-string-trim ">" actprofile3))
(setq copy_path (strcat (getvar "roamablerootprefix") "Support\\Profiles\\Profile.aws")) ; set current User AWS file path
(setq copy_path2 (strcat (getvar "roamablerootprefix") "Support\\Profiles\\" actprofile2 "\\Profile.aws"))
;   (princ actprofile2)
;(princ copy_path2)
;  (princ copy_path)
(setq fso (vlax-create-object "Scripting.FilesystemObject")) ; function used tp copy files
(vlax-invoke-method fso 'CopyFile (strcat "I:\\Engineering\\CAD Support files\\Profiles\\Profile.aws") copy_path :vlax-true) ;copies network/local backup AWS file to profile AWS location
(vlax-invoke-method fso 'CopyFile (strcat "I:\\Engineering\\CAD Support files\\Profiles\\Profile.aws") copy_path2 :vlax-true) ;copies network/local backup AWS file to profile AWS location 
 (vla-put-ActiveProfile acadProfiles actprofile) ; restore original User profile
(vla-deleteprofile (vla-get-profiles (vla-get-preferences (vlax-get-acad-object))) "temp") ; delete temp profile from list of usable profiles
)

It fully works I tested it on Autocad 2008 2010 and 2011

 

IT could use some cleaning, like it also places the profile.aws in the folder where the profile folder is(copy_path). Since it had some problems with that. But it could be just me.

  • 2 years later...
Posted

CADkitt did you ever get this to work for you. The Lisp works but there issue is with profile.aws file no porting right.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...