Author Topic: Adding code to an existing lisp  (Read 4503 times)

0 Members and 1 Guest are viewing this topic.

CECE_CAD

  • Guest
Adding code to an existing lisp
« on: February 26, 2008, 10:56:50 AM »
I got this good lisp from here and I would like to add to it.  How do I add steps to this at the end? 
I tried (command) but I'm thinking I'm not starting it correctly.  I want to add three more steps. 

Textfill
Insert
plot
 
Code: [Select]
;;  Function to delete all user plot set ups
(defun C:cxz (/ 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

JohnK

  • Administrator
  • Seagull
  • Posts: 10659
Re: Adding code to an existing lisp
« Reply #1 on: February 26, 2008, 11:33:35 AM »
Here's the first two in your list.  Plot, i dont think will work from within a lisp.

Well, anyways i commented your code and tried to make it customizable for you.

Code: [Select]
(defun C:cxz (/ curdwg pslayout x
                ; local procedures
                do-some-stuff )
  (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

    ;; a helper procedure incase you want to add more.
    ;; this wont work for plot and few other commands.
  (defun do-some-stuff ( process )
    ;; simple command processor;
    ;; command is issued and waits till
    ;; user is done.
    (command process)
    (command "~")
    (while (eq (logand (getvar 'CMDACTIVE)) 1)
           (command PAUSE)) )

  ;; set the textfill var to one (1)
  (setvar 'TEXTFILL 1)
  ;; let the user insert a block
  (do-some-stuff "insert")

)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

CECE_CAD

  • Guest
Re: Adding code to an existing lisp
« Reply #2 on: February 26, 2008, 11:50:07 AM »
Thanks for the help.  Yeah I was going about it all wrong!! :lol:
For this part 
Code: [Select]
  ;; let the user insert a block
  (do-some-stuff "insert")
  will it work if I put what I need to be inserted?  Its only the new plot settings.  I insert them..

Code: [Select]
(do-some-stuff "insert" "what i want inserted")

JohnK

  • Administrator
  • Seagull
  • Posts: 10659
Re: Adding code to an existing lisp
« Reply #3 on: February 26, 2008, 12:01:42 PM »
Nope, that would be something a bit different. Something like:
(command "insert" <YOUR BLOCKNAME> "0,0" "1" "" "")

if you know what you want, why dont you give me the details and i will redo the code for you.

TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

CECE_CAD

  • Guest
Re: Adding code to an existing lisp
« Reply #4 on: February 26, 2008, 01:19:07 PM »
ok, thanks!!  :-D 
well you did help, and that is appreciated.  let see, I'm inserting a drawing file that has my page setup.  I have a button thats doing this:
Code: [Select]
^C^CTEXTFILL;1;-insert;K:/settings/CECEPlotSettings;^C^Cplot;   I want this to be with that lisp now but at the end.  I have alot of old "old" files that still have OLD settings that I want purged.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Adding code to an existing lisp
« Reply #5 on: February 26, 2008, 01:21:04 PM »
Since you are just "calling" the plot function, I think you might be able to add that at the end of the lisp

Code: [Select]
...
...
  ;; set the textfill var to one (1)
  (setvar 'TEXTFILL 1)
  ;; let the user insert a block
  (command "insert" "K:/settings/CECEPlotSettings")
(command)
(command "plot")
)

this might work
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

JohnK

  • Administrator
  • Seagull
  • Posts: 10659
Re: Adding code to an existing lisp
« Reply #6 on: February 26, 2008, 01:26:35 PM »
no problem.

*lol* so why dont you just modify the button instead of the lisp?!

If you use the first lisp you posted, your button could be something like:
Code: [Select]
^C^C(C:cxz);TEXTFILL;1;-insert;K:/settings/CECEPlotSettings;^C^Cplot;
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Adding code to an existing lisp
« Reply #7 on: February 26, 2008, 01:28:57 PM »
Hey Se7en, would you need the () or just ^C^C^Ccxz;  ?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

JohnK

  • Administrator
  • Seagull
  • Posts: 10659
Re: Adding code to an existing lisp
« Reply #8 on: February 26, 2008, 01:32:24 PM »
'Hey' right back at cha.

I think both work ... Let me check.

yep, both work
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Adding code to an existing lisp
« Reply #9 on: February 26, 2008, 01:36:15 PM »
cool, learned something new
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

CECE_CAD

  • Guest
Re: Adding code to an existing lisp
« Reply #10 on: February 26, 2008, 01:36:44 PM »
 :?  lol, wow!! ummm.. its because I put too much thought into things instead of trying to make things easy for myself...   :ugly:  also, still learning about lisping and was trying to see if I could add to what I had.  

CECE_CAD

  • Guest
Re: Adding code to an existing lisp
« Reply #11 on: February 26, 2008, 01:42:35 PM »
yeah, and you just taught me something new that I didnt know....   :-D   
I didn't know that you could do this
Code: [Select]
(C:cxz) after ^c^c..  So thanks!

JohnK

  • Administrator
  • Seagull
  • Posts: 10659
Re: Adding code to an existing lisp
« Reply #12 on: February 26, 2008, 01:49:28 PM »
No problem. I do that all the time.

If you want to learn Lisp, i suggest trying out a simple command and asking one of us to help you get started.


Cmdr, Yeah i didnt know you could do the opposite so i learned something too.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: Adding code to an existing lisp
« Reply #13 on: February 26, 2008, 02:07:20 PM »
nice
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

CECE_CAD

  • Guest
Re: Adding code to an existing lisp
« Reply #14 on: February 26, 2008, 03:18:44 PM »
That's me.. Trying to jump in head first...  i'm going to try, I want to learn  :lol:   Thanks for your help!