Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Combind two lisp routines

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
vivifira
541 Views, 5 Replies

How to Combind two lisp routines

Hello again all,

 

So I've written two routines that when I run them seperatly I get the effect I want, but I want them to run one after the other. I just simply want to draw a pline and after I'm done drawing the pline I want it to automaticlly offset to the side I have picked. Here's what I have come up with so far and I can't figure out how to get the routines to run together. Please help.

 


(vl-load-com)
 
(defun c:ridge () 
(setq p1 (getpoint "\nSelect start of ridge: "))
(command "pline" p1)

 ); defun
(princ)


(vlr-command-reactor
 nil '((:vlr-commandEnded . endCommand)))
(vlr-command-reactor
 nil '((:vlr-commandCancelled . cancelCommand)))


(defun endCommand (calling-reactor endcommandInfo /
     thecommandend)
  (setq thecommandend (nth 0 endcommandInfo))
  (if
  (= thecommandend "PLINE")
   (setq p2(getpoint "\nPick Which Side to Offset"  ) )
)

  (princ)
);defun

 

  (defun cancelCommand (calling-reactor cancelcommandInfo /
        thecommandcancel)
(setq thecommandcancel (nth 0 cancelcommandInfo))
    (cond
  ((= thecommandcancel "PLINE") (prompt "\nRidge Aborted"))
  (exit)
)
 (princ)
);defun


(defun roffset()
 (command "offset" "3'" p1 p2 "")
  )
(princ)

 

 

5 REPLIES 5
Message 2 of 6
scot-65
in reply to: vivifira

First of all, LOOSE THOSE REACTORS. You do not need them.

Be familiar with LISP first before moving on to the VL* items.

For this type of program you do not need reactors.

 

One method:

 

(if (and

  (setq p1 (getpoint "Specify first point: "))

  (setq p2 (getpoint p1 "end point: "))

  (setq p3 (getpoint p2 "Side of offset: ")) );and

 (progn

  [turn off osmode]

  [draw the pline using p1 and p2]

  [offset command using (ENTLAST) and p3]

  [restore osmode]

 );progn

 (alert "Ridge aborted.  ")

);if

;conceptual

 

Notice this program structure.

All user input is gathered (and tested) before the program executes.

This is key in successful program writing.

 

"Never underestimate the ingenuity of complete fools."


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 3 of 6
vivifira
in reply to: scot-65

I like the use of alert instead of my reactor and I do agree I need to become more familiar with lisp first before tackling vl items. The problem I'm having there is that it's all a big jumbled mess on the net. I'm teaching myself lisp, vlisp, and activex right now because my work is slow and this is how I'm trying to help out in the office right now. I'm trying to automate as many tasks for my co-workers as I can. Your method is defiantly cleaner than mine but I wrote it this way because my coworkers and I will be plotting more than two point on this line. I suppose I could write a loop to achieve this but then I have the problem of how to activate the offset after my loop is done........ I think I'll explore this option a little father. Thanks for the advice
Message 4 of 6
hmsilva
in reply to: vivifira

Another method:

 

(defun c:test (/ las las1)
  (setq las (entlast))
  (command "_.pline")
  (while (> (getvar 'cmdactive) 0)
    (command pause)
  ); end while
  (if (not (eq (setq las1 (entlast)) las))
    (vl-cmdf "_.offset" "3" las1 pause "")
  )
  (princ)
)

HTH

Henrique

 

EESignature

Message 5 of 6
vivifira
in reply to: hmsilva

Thanks! That's perfect! I didn't know that a pause command existed. Thank you guys for your help.
Message 6 of 6
hmsilva
in reply to: vivifira

You're welcome, vivifira
Glad I could help

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost