Author Topic: Can a user have a custom preference saved?  (Read 130 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2562
  • I can't remeber what I already asked! I need help!
Can a user have a custom preference saved?
« on: June 27, 2022, 11:25:28 AM »
Maybe the question is to vague, I have some users that want there "startup" to be on a certain layer. (For Example. Layer 0 set to C-NPLT (no plot) Layer).

I know I could write a routine that I could load in each users startup. But there are alot of users.

Would there be a method to have a user activate this command to turn it on. And then if the user would want to turn it off.

Code: [Select]
(command "-layer" "set" "C-NPLT" "")
Once, the command is turned on, it would always be on for each session of AutoCAD until the user decides to turn it off?

Sorry for rambling on.  Thank you for any ideas on this one.
Civil3D 2020

mhupp

  • Newt
  • Posts: 172
Re: Can a user have a custom preference saved?
« Reply #1 on: June 27, 2022, 11:53:21 AM »
Make a "stat-up" lisp here is mine

Code - Auto/Visual Lisp: [Select]
  1. (setvar 'cmdecho 0)
  2. (setvar 'INSUNITS 1)        ; Sets the Drawing units to inches
  3. (setvar 'THICKNESS 0)       ; Sets THICKNESS TO 0
  4. (setvar 'CECOLOR "BYLAYER") ; Sets color property to "BYLAYER."
  5. (setvar 'CELTYPE "BYLAYER") ; Sets linetype property to "BYLAYER."
  6. (setvar 'CELWEIGHT -1)      ; Sets the lineweight to "BYLAYER."
  7. (setvar 'CELTSCALE 1)       ; Sets the LTScale of new objects to 1.
  8. (setvar 'plinetype 2)       ; convents all 2D polylines to optimized polylines  
  9. (setvar 'auprec 4)              ; angular unit percision 0.0000
  10. (setvar 'luprec 4)              ; linear unit percision 0.0000
  11. (setvar 'selectionmodes 0)  ; Set Selection mode to 0
  12. (setvar 'lunits 2)          ; Set Linear units to Decimal
  13. (setvar 'perspective 0)     ; Turn off Perspective view in current viewport
  14. (setvar 'saveformat 8)          ; Set save to 2010 DXF
  15. (setvar 'nomutt 1)
  16. (vl-cmdf "_.Style" "Standard" "Consolas" "" "" "" "" "")
  17. (setvar 'nomutt 0)
  18. (setvar 'cmdecho 1)

Save it to a trusted file path

Then use appload drag lisp to startup suite the briefcase should run each time you open a file.


use
(servar 'clayer "C-NPLT") instead of (command "-layer" "set" "C-NPLT" "")



JohnK

  • Administrator
  • Seagull
  • Posts: 10140
Re: Can a user have a custom preference saved?
« Reply #2 on: June 27, 2022, 03:52:05 PM »
Not a good solution but thinking outside the box a bit; I've always wanted to play with something like the following:

Code - Auto/Visual Lisp: [Select]
  1. (defun hook (func)
  2.   ;; hook
  3.   ;; this function will take an argument and turn it into a
  4.   ;; lambda expression to evaluate. (You can assign to a variable
  5.   ;; and exec it at a later time if you wish.)
  6.   ;;
  7.   ;; By: John (Se7en) K
  8.   ;;    (inspired by something I saw in one of
  9.   ;;     Vladimir Nesterovsky's procedures.)
  10.   ;;
  11.   ;; Ex: (hook '(+ 1 2))
  12.   ;;     > ((LAMBDA nil (+ 1 2)))
  13.   ;;    
  14.   (list (cons 'lambda (cons nil (list func)))) )

I mean "play" as in, something like this:

Code: [Select]
Command: (setq a (hook '(+ 1 2)))
((LAMBDA nil (+ 1 2)))
Command: (eval a)
3
Command: (setq a (hook (cons '- (cdr (car (cddr (car a)))))))
((LAMBDA nil (- 1 2)))
Command: (eval a)
-1

...but you can achieve something very, very similar with no support routines (and probably far better too) --i.e. `hook`-- with defun-q so I've never taking it further then what you see here.
TheSwamp.org (serving the CAD community since 2003)

Donate to TheSwamp.org

danAllen

  • Newt
  • Posts: 46
Re: Can a user have a custom preference saved?
« Reply #3 on: June 27, 2022, 05:02:22 PM »
I created a routine to load a users lisp file from network folder. The office standard lisps would look for a file called xyz_user.lsp, in a folder named for (getvar "LOGINNAME") under a common staff folder on network (..\\staff\\Dan), and load it if found.