Jump to content

CUI to unload LISP


Randolph

Recommended Posts

  • Replies 36
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    16

  • Randolph

    15

  • JeepMaster

    4

  • The Buzzard

    1

The biggest thing that puzzles me is why people don't use the number key row.

~ = qleader
1 = layer current
2 = layer set
3 = layer off
4 = layer freeze
5 = mleader
6 = civilpointmodlist (old LDD command, need to update since I use C3D now)
7 = list
8 = layerp
9 = extrim
0 = math (commandline calculator)
- = layer nuke
= = never defined, but could be used

Hey, thanks for that idea. I will try it out.:)

Link to comment
Share on other sites

How about:

 

^1 top view

^2 side view, ucs world (to stop the annoying rotation of the ucs)

^3 front view, ucs world

...

^6 iso ... and so on

Link to comment
Share on other sites

How about:

 

^1 top view

^2 side view, ucs world (to stop the annoying rotation of the ucs)

^3 front view, ucs world

...

^6 iso ... and so on

 

 

Whatever tickles your fancy. It's really what makes life easier for the specific user. What I like, isn't the best for someone else.

Link to comment
Share on other sites

So, I tried it out now:

 

To load a contradicting lisp works.

 

 
acad-ralph.lsp 

(DEFUN C:S ()(COMMAND "_SLICE"))

 

 
acad-martin.lsp

(DEFUN C:S ()(COMMAND "_MOVE"))

 

Whatever lsp I appload, the command changes.

 

BUT

 

if I change the profiles (options > profiles > acad-ralph / acad-martin), the corresponding lsp does NOT load.

 

I did the following: Set profile acad-ralph, appload and put acad-ralph to the START GROUP. Change profile to acad-martin, remove acad-ralph.lsp from the start group and add acad-martin.lsp. But when I changed back to profile acad-ralph, this did not change back.

 

Now I will try the above routine.

Link to comment
Share on other sites

This I wrote into my lisp:

 

 
(DEFUN C:CSW (/ ProfileLoad #Choice)
 (vl-load-com)
 (defun ProfileLoad (#ProfileName / #Profiles)
   (setq
     #Profiles
      (vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
   ) ;_ setq
   (or (eq #ProfileName (vla-get-activeprofile #Profiles))
       (not (vl-catch-all-error-p
              (vl-catch-all-apply
                'vla-put-activeprofile
                (list #Profiles #ProfileName)
              ) ;_ vl-catch-all-apply
            ) ;_ vl-catch-all-error-p
       ) ;_ not
   ) ;_ or
 ) ;_ defun
 (initget 0 "Ralph Martin Dismiss")
 (and (setq #Choice
             (getkword
               "\nUser customization options to load [Ralph/Martin] <Dismiss>: "
             ) ;_ getkword
      ) ;_ setq
      (cond
        ((eq #Choice "Ralph")
         ;; do stuff
         (ProfileLoad "AutoCAD - Ralph")
         (and (findfile "acad-ralph.lsp") (load "acad-ralph.lsp"))
        )
        ((eq #Choice "Martin")
         ;; do stuff
         (ProfileLoad "AutoCAD - Martin")
  (and (findfile "acad-martin.lsp") (load "acad-[color=red]martin[/color].lsp")) 
        )
      ) ;_ cond
 ) ;_ and
 (prin
) ;_ defun
)

 

But it does NOT load the lisp. Mybe it doesn't find the file? If I appload acad-martin.lsp and then acad-ralph.lsp manualy afterwards, everthing works. Should I enter a path instead of "findfile"?:(

Link to comment
Share on other sites

Furthermore

 

 
Befehl: csw
User customization options to load [Ralph/Martin] <Dismiss>: m
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: ACAD
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: CUSTOM
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: MARTIN
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: ACROBAT_COMMENT
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: ADOBE_PDF
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: EXPRESS
[color=red]; Fehler: no function definition: PRIN[/color]
Befehl:

 

Befehl means command.

Fehler means error.

 

It doesn't state that it loaded acad-martin.lsp.

Link to comment
Share on other sites

Furthermore

 

 
Befehl: csw
User customization options to load [Ralph/Martin] <Dismiss>: m
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: ACAD
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: CUSTOM
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: MARTIN
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: ACROBAT_COMMENT
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: ADOBE_PDF
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: EXPRESS
[color=red]; Fehler: no function definition: PRIN[/color]
Befehl:

Befehl means command.

Fehler means error.

 

It doesn't state that it loaded acad-martin.lsp.

Look at the last lines of the code:

 

  ) ;_ and
 ([color=Red]prin[/color]
) ;_ defun
)

 

 

As far as it not loading, the files must be in a support path or the path must be specified. Just add the directory to your support paths.

Link to comment
Share on other sites

negative: the problem was that somehow your code

 

  ) ;_ cond
 ) ;_ and
 (princ)
) ;_ defun

 

was mutilated to

 

  ) ;_ cond
 ) ;_ and
 [color=red](prin
[/color]) ;_ defun

 

BUT it still does not APPLOAD. This is what I get now:

 

 
Befehl: csw
User customization options to load [Ralph/Martin] <Dismiss>: m
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: ACAD
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: CUSTOM
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: MARTIN
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: ACROBAT_COMMENT
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: ADOBE_PDF
Anpassungsdatei erfolgreich geladen. Anpassungsgruppe: EXPRESS
Befehl:

 

If I do the CSW command and APPLOAD the matching LISP, everything is fine. Why does CSW not appload? I'm not able to find the error. :(

Link to comment
Share on other sites

I got it:

 

 
(DEFUN C:CSW (/ ProfileLoad #Choice)
 (vl-load-com)
 (defun ProfileLoad (#ProfileName / #Profiles)
   (setq
     #Profiles
      (vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
   ) ;_ setq
   (or (eq #ProfileName (vla-get-activeprofile #Profiles))
       (not (vl-catch-all-error-p
              (vl-catch-all-apply
                'vla-put-activeprofile
                (list #Profiles #ProfileName)
              ) ;_ vl-catch-all-apply
            ) ;_ vl-catch-all-error-p
       ) ;_ not
   ) ;_ or
 ) ;_ defun
 (initget 0 "Ralph Martin Dismiss")
 (and (setq #Choice
             (getkword
               "\nUser customization options to load [Ralph/Martin] <Dismiss>: "
             ) ;_ getkword
      ) ;_ setq
      (cond
        ((eq #Choice "Ralph")
         ;; do stuff
         (ProfileLoad "AutoCAD - Ralph")
  [b][color=seagreen](and (load "C:/Programme/ADT2007/LISP/acad-ralph.lsp"))[/color][/b]
        )
        ((eq #Choice "Martin")
         ;; do stuff
         (ProfileLoad "AutoCAD - Martin")
[b][color=seagreen](and (load "C:/Programme/ADT2007/LISP/acad-martin.lsp"))[/color][/b]
        )
      ) ;_ cond
 ) ;_ and
 (princ)
) ;_ defun

 

Thanks Alan! :D

Link to comment
Share on other sites

(DEFUN C:CSW (/ ProfileLoad #Choice)
 (vl-load-com)
 (defun ProfileLoad (#ProfileName / #Profiles)
   (setq
     #Profiles
      (vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
   ) ;_ setq
   (or (eq #ProfileName (vla-get-activeprofile #Profiles))
       (not (vl-catch-all-error-p
              (vl-catch-all-apply
                'vla-put-activeprofile
                (list #Profiles #ProfileName)
              ) ;_ vl-catch-all-apply
            ) ;_ vl-catch-all-error-p
       ) ;_ not
   ) ;_ or
 ) ;_ defun
 (initget 0 "Ralph Martin Dismiss")
 (and (setq #Choice
             (getkword
               "\nUser customization options to load [Ralph/Martin] <Dismiss>: "
             ) ;_ getkword
      ) ;_ setq
      (cond
        ((eq #Choice "Ralph")
         ;; do stuff
         (ProfileLoad "AutoCAD - Ralph")
         (and (findfile "acad-ralph.lsp") (load "acad-ralph.lsp"))
        )
        ((eq #Choice "Martin")
         ;; do stuff
         (ProfileLoad "AutoCAD - Martin")
  (and (findfile "acad-martin.lsp") (load "acad-martin.lsp")) 
        )
      ) ;_ cond
 ) ;_ and
 (princ)
) ;_ defun

 

 

You don't need to be using AppLoad (unless you want to use it for the above code CSW). the acad-martin.lsp, either needs to be in a support path, or specify the path in the above lisp.

 

Without having acad-martin.lsp loaded, type (findfile "acad-martin.lsp"). Do you get nil or a directory string?

Link to comment
Share on other sites

I got it:

 

 
(DEFUN C:CSW (/ ProfileLoad #Choice)
 (vl-load-com)
 (defun ProfileLoad (#ProfileName / #Profiles)
   (setq
     #Profiles
      (vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
   ) ;_ setq
   (or (eq #ProfileName (vla-get-activeprofile #Profiles))
       (not (vl-catch-all-error-p
              (vl-catch-all-apply
                'vla-put-activeprofile
                (list #Profiles #ProfileName)
              ) ;_ vl-catch-all-apply
            ) ;_ vl-catch-all-error-p
       ) ;_ not
   ) ;_ or
 ) ;_ defun
 (initget 0 "Ralph Martin Dismiss")
 (and (setq #Choice
             (getkword
               "\nUser customization options to load [Ralph/Martin] <Dismiss>: "
             ) ;_ getkword
      ) ;_ setq
      (cond
        ((eq #Choice "Ralph")
         ;; do stuff
         (ProfileLoad "AutoCAD - Ralph")
  [b][color=seagreen](and (load "C:/Programme/ADT2007/LISP/acad-ralph.lsp"))[/color][/b]
        )
        ((eq #Choice "Martin")
         ;; do stuff
         (ProfileLoad "AutoCAD - Martin")
[b][color=seagreen](and (load "C:/Programme/ADT2007/LISP/acad-martin.lsp"))[/color][/b]
        )
      ) ;_ cond
 ) ;_ and
 (princ)
) ;_ defun

Thanks Alan! :D

 

 

If you are going just load it, you don't need the and statement.

Link to comment
Share on other sites

does the "and" hurt anybody, or is it for the beauty of programming? (which is still a good reason).

 

one thing i'm thinking is to make 2 commands: um (umschalten=switch martin) and ur. would be even faster.

Link to comment
Share on other sites

does the "and" hurt anybody, or is it for the beauty of programming? (which is still a good reason).

 

one thing i'm thinking is to make 2 commands: um (umschalten=switch martin) and ur. would be even faster.

It doesn't hurt anything, but it's superfluous since you removed the findfile check.

(and (findfile "blah")

(load "blah")

)

I would fill the additional parameter to the load function. Right now, if it can't find the file, it errors. Instead use (load "blah.lsp" "blah.lsp did not load") or just (load "blah.lsp" nil) would be better. That way it will load if finds and nil if not.

 

I could have also used if, but I didn't have an if this, then this, if not, then this situation, so I used and. Truthfully, (load "blah.lsp" nil) would have been the best and quickest solution. No reason to check if it exists if the loading function can handle not finding the file.

Link to comment
Share on other sites

  • 1 month later...

I just tried to make this to be 2 commands. 1 command UMM (Switch to profile Martin) and 1 command UMR (switch to profile Ralph). I also tried to remove the "and" statement. I ended up with AutoCAD stating

 

"wrong type of argument"

 

This is what I tried:

 

 
DEFUN C:UMR (/ ProfileLoad #Choice)
 (vl-load-com)
 (defun ProfileLoad (#ProfileName / #Profiles)
   (setq
     #Profiles
      (vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
   ) ;_ setq
   (or (eq #ProfileName (vla-get-activeprofile #Profiles))
       (not (vl-catch-all-error-p
              (vl-catch-all-apply
                'vla-put-activeprofile
                (list #Profiles #ProfileName)
              ) ;_ vl-catch-all-apply
            ) ;_ vl-catch-all-error-p
       ) ;_ not
   ) ;_ or
 ) ;_ defun
         (ProfileLoad "AutoCAD - Ralph")
(load "C:/Programme/ADT2007/LISP/acad-ralph.lsp")
      ) ;_ cond
 ) ;_ and
 (princ)
) ;_ defun

 

To be quite honest, I don't understand the (/ ProfileLoad #Choice)

part.

Link to comment
Share on other sites

I just tried to make this to be 2 commands. 1 command UMM (Switch to profile Martin) and 1 command UMR (switch to profile Ralph). I also tried to remove the "and" statement. I ended up with AutoCAD stating

 

"wrong type of argument"

 

This is what I tried:

 

 
DEFUN C:UMR (/ ProfileLoad #Choice)
 (vl-load-com)
 (defun ProfileLoad (#ProfileName / #Profiles)
   (setq
     #Profiles
      (vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
   ) ;_ setq
   (or (eq #ProfileName (vla-get-activeprofile #Profiles))
       (not (vl-catch-all-error-p
              (vl-catch-all-apply
                'vla-put-activeprofile
                (list #Profiles #ProfileName)
              ) ;_ vl-catch-all-apply
            ) ;_ vl-catch-all-error-p
       ) ;_ not
   ) ;_ or
 ) ;_ defun
         (ProfileLoad "AutoCAD - Ralph")
(load "C:/Programme/ADT2007/LISP/acad-ralph.lsp")
      ) ;_ cond
 ) ;_ and
 (princ)
) ;_ defun

To be quite honest, I don't understand the (/ ProfileLoad #Choice)

part.

 

 

 

LoL What a mess. :P Nah, you just missed the ( at the beginning and had too many parens at the end.

 

Give this a try:

(defun C:UMR (/ ProfileLoad)
 (vl-load-com)
 (defun ProfileLoad (#ProfileName / #Profiles)
   (setq
     #Profiles
      (vla-get-profiles (vla-get-preferences (vlax-get-acad-object)))
   ) ;_ setq
   (or (eq #ProfileName (vla-get-activeprofile #Profiles))
       (not (vl-catch-all-error-p
              (vl-catch-all-apply
                'vla-put-activeprofile
                (list #Profiles #ProfileName)
              ) ;_ vl-catch-all-apply
            ) ;_ vl-catch-all-error-p
       ) ;_ not
   ) ;_ or
 ) ;_ defun
 (ProfileLoad "AutoCAD - Ralph")
 (load "C:/Programme/ADT2007/LISP/acad-ralph.lsp" nil)
 (princ)
) ;_ defun

 

 

(/ ProfileLoad #Choice) is there to localize the subroutine and the variable. I removed #Choice since you don't need it.

Link to comment
Share on other sites

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...