Windows Tech Support

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Saturday, 31 March 2012

VLDB Code Example: Reload Profile From .ARG

Posted on 08:25 by Unknown
Another set of code from Chapter 19, of my book "The Visual LISP Developer's Bible (2011 Edition)" available on Amazon for Kindle and Kindle Reader apps.  This one reloads an existing AutoCAD Profile from a source .ARG file.  As you may know, if you load an .ARG file, it is imported into the Registry.  Each time you launch AutoCAD, if the shortcut or command line specifies /P to specify a Profile (even a full path to an .ARG file) if a Profile already exists (by the same name) in the Registry, the .ARG file is ignored and the Profile is loaded from the Registry.  This is pretty much the same way a web browser cache works when loading stored images.  If you want it to force a reload from the source .ARG file, here's one way to do it...

;;; Reloads a profile from an ARG file
;;; Replaces existing profile if defined
;;; Returns profile name if successful, otherwise returns nil


(defun Profile-Reload (name ARGname / bogus)
(cond
( (and
(Profile-Exists-p name)
(findfile ARGname)
)
(if (/= (strcase name) (strcase (vla-get-ActiveProfile (AcadProfiles))))
(Profile-Delete name)
(progn
(setq bogus "bogus")
(Profile-Rename name bogus)
)
)
(Profile-Import name ARGname)
(vla-put-ActiveProfile (AcadProfiles) name)
(if bogus (Profile-Delete bogus))
name
)
( (and
(not (Profile-Exists-p name))
(findfile ARGname)
)
(Profile-Import name ARGname)
(vla-put-ActiveProfile (AcadProfiles) name)
name
)
( (not (findfile ARGname))
(princ (strcat "\nCannot locate ARG source: " ARGname)) nil
)
)
)

;;; Renames an existing profile
;;; Returns new profile name if successful, otherwise returns nil


(defun Profile-Rename (from to / result)
(if (Profile-Exists-p from)
(if (not (Profile-Exists-p to))
(cond
( (not
(vl-catch-all-error-p
(setq result
(vl-catch-all-apply
'vla-RenameProfile
(list (AcadProfiles) from to)
)
)
)
) to ; Return new name if successful!
)
)
)
)

;;; Deletes an existing profile
;;; Returns T if successful, otherwise returns nil

(defun Profile-Delete (strName / result)
(if (Profile-Exists-p strName)
(cond
( (not
(vl-catch-all-error-p
(setq result
(vl-catch-all-apply
'vla-DeleteProfile
(list (AcadProfiles) strName)
)
)
)
)
T ; return T for success!
)
)
)
)

;;; Imports a profile from a given ARG file
;;; Returns profile name if successful, otherwise returns nil


(defun Profile-Import (argFile strName / result)
(cond
( (findfile argFile)
(cond
( (not
(vl-catch-all-error-p
(setq result
(vl-catch-all-apply
'vla-ImportProfile
(list (AcadProfiles) strName argFile vlax-True)
)
)
)
)
strName ; return new profile name if successful!
)
)
)
)
)

;;; Determine if profile name is already defined (exists)
;;; Returns T or nil

(defun Profile-Exists-p (name)
(get-item (AcadProfiles) name)
)

;;; Return Profiles collection object

(defun AcadProfiles ()
(vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
)
The Visual LISP Developers Bible – 2011 Edition
http://sites.google.com/site/visuallispbible
Copyright ©2002-2010 David M. Stein, All Rights Reserved.
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in amazon, autocad, books, programming, visual lisp | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

Categories

  • a
  • activation
  • active directory
  • advertising
  • agile
  • agility
  • amazon
  • american
  • apple
  • application virtualization
  • applications
  • art
  • articles
  • asp
  • augi
  • authors
  • autocad
  • AutoCAD Autodesk
  • autodesk
  • autolisp
  • automation
  • automotive
  • backups
  • batch
  • beer
  • beta
  • blackberry
  • blogs
  • bongloads
  • book
  • books
  • Books writing kindle amazon technology business projects
  • browsers
  • business
  • cad
  • career
  • certification
  • chrome
  • city government
  • civilization
  • cloud services
  • cmd
  • cmmi
  • comedy
  • command
  • community
  • computers
  • conferences
  • config manager
  • consultants
  • consulting
  • contracting
  • cranium drainium
  • crapware
  • culture
  • data center
  • data mining
  • databases
  • deployment
  • directx
  • DLL
  • domains
  • dumb
  • earth
  • economy
  • editor
  • education
  • election
  • elections
  • employment
  • engineering
  • entertainment
  • environment
  • error monitoring
  • events
  • exchange
  • facebook
  • family
  • firefox
  • flexnet
  • fud
  • fun
  • funny
  • games
  • gary vaynerchuk
  • gmail
  • google
  • government
  • group policy
  • hampton roads
  • health
  • history
  • holidays
  • home
  • html5
  • humor
  • hyper-v
  • iis
  • industry
  • infrastructure
  • installation
  • installshield
  • internet
  • internet explorer
  • interviews
  • jobs
  • jtbworld
  • kindle
  • kixtart
  • lab setup
  • languages
  • ldap
  • learning
  • legal
  • licensing
  • life
  • lifecycle
  • linux
  • lisp
  • logging
  • management
  • manufacturing
  • marketing
  • markets
  • mdop
  • mdt
  • medical
  • messaging
  • microsoft
  • microsoft access
  • military
  • mountains
  • movies
  • mozilla
  • music
  • nature
  • network administration
  • news
  • nook
  • nothing
  • office
  • open source
  • openoffice
  • opera
  • operating systems
  • oracle
  • osx
  • packaging
  • patches
  • people
  • photos
  • podcasts
  • policy
  • politics
  • powershell
  • predictions
  • process automation
  • products
  • programming
  • projects
  • psychology
  • publishing
  • rail
  • reading
  • registry
  • religion
  • reporting
  • reviews
  • rsat
  • rss
  • safari
  • safety
  • sales
  • satire
  • sccm
  • scheduling
  • science
  • scripting
  • search
  • security
  • servers
  • services
  • sharepoint
  • shopping
  • sms
  • social stuff
  • society
  • softgrid
  • software assurance
  • software deployment
  • software development
  • software packaging
  • sony
  • speaking
  • sports
  • sql express
  • sql server
  • statistics
  • Statistics news marketing
  • steve jobs
  • stories
  • stuff
  • stupidity
  • symantec
  • sysinternals
  • system center
  • systems architecture
  • t-sql
  • taxes
  • technet
  • technical support
  • technology
  • TED
  • ted talks
  • testing
  • textpad
  • thoughts
  • traffic
  • training
  • transportation
  • travel
  • troubleshooting
  • tutorials
  • twitter
  • ubuntu
  • unattend
  • unemployment
  • updates
  • upfront ezine
  • utilities
  • vacation
  • vba
  • vbscript
  • video
  • virginia
  • virginia beach
  • virtualization
  • visual lisp
  • vmware
  • vmware server
  • voting
  • war
  • weather
  • web
  • web browsers
  • web development
  • web sites
  • windows
  • windows 7
  • windows live
  • windows server
  • windows server 2012
  • windows8
  • winpe
  • wise
  • wmi
  • work
  • writing
  • ws08
  • wsus
  • wwa
  • x64
  • xml
  • ze frank

Blog Archive

  • ►  2013 (37)
    • ►  October (1)
    • ►  September (5)
    • ►  August (8)
    • ►  July (2)
    • ►  June (4)
    • ►  May (4)
    • ►  April (2)
    • ►  March (2)
    • ►  February (8)
    • ►  January (1)
  • ▼  2012 (120)
    • ►  December (14)
    • ►  November (12)
    • ►  October (10)
    • ►  September (7)
    • ►  August (3)
    • ►  July (2)
    • ►  June (6)
    • ►  May (6)
    • ►  April (20)
    • ▼  March (16)
      • Disabling InfoCenter in AutoCAD 2013
      • VLDB Code Example: Reload Profile From .ARG
      • VLDB Code Example: Purge All Opened Drawings
      • Windows 8 - What I Think About It
      • VLISP Housecleaning: Example 2
      • VLISP House Cleaning Project
      • The Mid-Level IT Manager
      • LDAP User Account Properties: The WMI way
      • IAQ Time
      • SxSWi Article
      • Software Distribution - What is does it mean?
      • State of the Tech Industry: Sort Of.
      • Don't Be Afraid to Ask
      • Windows 8 or Windows 7 R2 (?)
      • Don't be THAT Douchebag, mm-kay?
      • Windows 8 Task Manager
    • ►  February (18)
    • ►  January (6)
  • ►  2011 (343)
    • ►  December (15)
    • ►  November (23)
    • ►  October (27)
    • ►  September (35)
    • ►  August (29)
    • ►  July (17)
    • ►  June (23)
    • ►  May (20)
    • ►  April (38)
    • ►  March (61)
    • ►  February (54)
    • ►  January (1)
Powered by Blogger.

About Me

Unknown
View my complete profile