With calling other routines in a main routine

With calling other routines in a main routine

rolisonfelipe
Collaborator Collaborator
1,131 Views
10 Replies
Message 1 of 11

With calling other routines in a main routine

rolisonfelipe
Collaborator
Collaborator
With calling other routines in a main routine, type:
(Defun: C: Main routine ()
   (Routine 01)
   (routine 02)
   (routine 03)
)
(Defun: C: Routine 01 ()
   (BLÁBLÁBLÁBLA)
   (Do this)
   etc
)
(Defun: C: Routine 02 ()
   (BLÁBLÁBLÁBLA)
   (Do this)
   etc
)
(Defun: C: Routine 03 ()
   (BLÁBLÁBLÁBLA)
   (Do this)
   etc
)
 
0 Likes
Accepted solutions (4)
1,132 Views
10 Replies
Replies (10)
Message 2 of 11

DannyNL
Advisor
Advisor
Accepted solution

Not sure if there is a question, but you could also define the subroutines within your main routine if they are not used outside the main routine.

 

(Defun: C:MainRoutine (/ Routine01 Routine02 Routine03)
   (Defun C:Routine01 ()
      (BLÁBLÁBLÁBLA)
      (Do this)
      etc
   )
   (Defun C:Routine02 ()
      (BLÁBLÁBLÁBLA)
      (Do this)
      etc
   )
   (Defun C:Routine03 ()
      (BLÁBLÁBLÁBLA)
      (Do this)
      etc
   )
   (Routine01)
   (Routine02)
   (Routine03)
)
0 Likes
Message 3 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

@rolisonfelipe wrote:
With calling other routines in a main routine, type:
(Defun: C:Mainroutine ()
   (c:Routine01)
   (c:routine02)
   (c:routine03)
)
(Defun: C:Routine01 ()
   (BLÁBLÁBLÁBLA)
   (Do this)
   etc
)
(Defun: C:Routine02 ()
   (BLÁBLÁBLÁBLA)
   (Do this)
   etc
)
(Defun: C:Routine03 ()
   (BLÁBLÁBLÁBLA)
   (Do this)
   etc
)
 

 

Include the c: if there is one.

And no spaces allowed.

Another solution is to link the routine like this

(defun c:Bla () MoreDetails )

 

For additional info look in help HERE 

0 Likes
Message 4 of 11

ВeekeeCZ
Consultant
Consultant

...Or if @DannyNL is correct in sense of understanding you, remove the c:

 


@DannyNL wrote:

Not sure if there is a question, but you could also define the subroutines within your main routine if they are not used outside the main routine.

 

(Defun: C:MainRoutine (/ Routine01 Routine02 Routine03)
   (Defun C:Routine01 ()
      (BLÁBLÁBLÁBLA)
      (Do this)
      etc
   )
   (Defun C:Routine02 ()
      (BLÁBLÁBLÁBLA)
      (Do this)
      etc
   )
   (Defun C:Routine03 ()
      (BLÁBLÁBLÁBLA)
      (Do this)
      etc
   )
   (Routine01)
   (Routine02)
   (Routine03)
)

 

Message 5 of 11

DannyNL
Advisor
Advisor

Yep....you're right. Missed that one Smiley Happy

0 Likes
Message 6 of 11

rolisonfelipe
Collaborator
Collaborator

Here we have two great solutions,
Note the  "Defun: " with  ": " It starts Lisp much faster, I liked it!!
By the way @ВeekeeCZ, I didn't know you had a programming aid. http://help.autodesk.com/view/ACD/2018
Is there a non CAD program to validate Lisp?

Thank you all, another great learning.....

0 Likes
Message 7 of 11

ВeekeeCZ
Consultant
Consultant

Well if you understand good enough to know when to use which, then good for you!

And yes, I'm aware of that little typo of yours, but kept that going since that was so obvious.

 


@rolisonfelipe wrote:

By the way @ВeekeeCZ, I didn't know you had a programming aid. http://help.autodesk.com/view/ACD/2018


Guess this should have some funny point, but I'm missing that since the link probably went wrong?!

 


@rolisonfelipe wrote:

Is there a non CAD program to validate Lisp?


I use the build-in VLIDE editor. Type VLIDE into command-line. Guess it's not non-cad solution you looking for?

Some other guys use Notepad++ or other editors... you can use Search to get more info about them. The build-in VLIDE editor probably the best for testing and tracing. But can't tell more since I didn't use them.

0 Likes
Message 8 of 11

rolisonfelipe
Collaborator
Collaborator
I have two questions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(vl-load-com)
(DEFUN C:ALL ()
    (C:LISP01)
   (C:LISP02)
    (C:LISP03)
(princ "\n DIGITE ALL ")
(PRINC)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN C:LISP01 ()
 (BLABLABLA)
        (setq TEXTSIZE ( (getdist (strcat "\n ESCALE 1: "))))
 (princ "\n SELECT OBJECT: ")
 (setq XX (ssget BLABLABLA))
 (Do it XX)
(PRINC)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN C:LISP01 ()
 (BLABLABLA)
 (princ "\n SELECT OBJECT: ")
 (setq YY (ssget BLABLABLA))
 (Do it YY)
(PRINC)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN C:LISP01 ()
 (BLABLABLA)
 (princ "\n SELECT OBJECT: ")
 (setq ZZ (ssget BLABLABLA))
 (Do it ZZ)
(PRINC)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
I have a main routine c:all that calls all the others, and all will act on the same object selected, then I ask:
01-has how to make a selection for all, or ssget has limitation at this point?
02-If there is another request how do I put all this in the main programming?
Because, my vision would be something like that....
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(vl-load-com)
(DEFUN C:ALL ()
    (C:LISP01)
   (C:LISP02)
    (C:LISP03)
        (setq TEXTSIZE1 ( (getdist (strcat "\n ESCALE 1: "))))
        (setq TEXTSIZE2 ( (getdist (strcat "\n ADD TEXT "))))
        (setq TEXTSIZE ( (getdist (strcat "\n ESCALE 1: "))))
 (princ "\n SELECT OBJECT: ")
 (setq ALLSELECT (ssget))
(princ "\n DIGITE ALL ")
(PRINC)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN C:LISP01 ()
 (BLABLABLA)
        ;(setq TEXTSIZE1 ( (getdist (strcat "\n ESCALE 1: "))))
 ;(princ "\n SELECT OBJECT: ")
 (setq ALLSELECT (XX))
 (ALLSELECT TEXTSIZE1)
 (Do it XX)
(PRINC)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN C:LISP01 ()
 (BLABLABLA)
        ;(setq TEXTSIZE2 ( (getdist (strcat "\n ADD TEXT "))))
 ;(princ "\n SELECT OBJECT: ")
 (setq ALLSELECT(YY))
 (ALLSELECT TEXTSIZE2 YY)
 (Do it YY)
(PRINC)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN C:LISP01 ()
 (BLABLABLA)
 ;(princ "\n SELECT OBJECT: ")
 (setq ALLSELECT (ZZ))
 (Do it ZZ)
(PRINC)
)
0 Likes
Message 9 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

Hello Felipe,

first of all, I would go back to the beginning... what do expect of this approach? Why do you fragment the code so much? As to beginner, I would suggest to forget about this at least for now and focus just on the functionality. The fragmenting only makes things more complicated. 

 

ad 01

Use the ssget. There is no limit. Look HERE

I suggest to use (setq ss (ssget "_X"))

ad 02 sorry, really don't understand the question. In the fact from your current code I'm unable to see your goal. There are too many bla-blas, too many same names....

0 Likes
Message 10 of 11

rolisonfelipe
Collaborator
Collaborator

Hello @ВeekeeCZ , Beginner's life and very complicated, nor learned to walk and already wants to fly... Lol.
But it's okay.
What I'm doing is putting together a set of functions that are already existing and programmed, assembling a complete, as I do not know how to reprogram I created a central command and attached several routines to the Central Command.
 And what was the problem, as all the subroutines request, I asked if it is possible to put this selection in the Central Command, and it would be a unique selection for all the subroutines, and the other remark if other small request command TBM could lead to the Central charge, but overall I'm going to well.... PQ I do not know to write a line of anything but I know to modify a thing here and there, and look that barely know English, I know more Japanese than English. Strong hug, but thanks plea the hint.

 

See in video the amount of selection

0 Likes
Message 11 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

I see. The problem is that this is really not that easy and it depends on circumstances!

But try this, but I'm not sure if your circumstances allows this: 

You need collect all user inputs first. Then as the very last thing you'll sent the code to the current drawing without any other user input:

 

Example:

(setq ss (ssget)) ; the use as the Previous selection

(setq hg1 (getdist "text heigh1"))

(setq hg2 (getdist "text heigh2"))

 

(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "Routine1\r_previous\r\r" (rtos hg1 2 6))

(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) (strcat "Routine2\r_previous\r\r" (rtos hg2 2 6))

 

You need to have (vl-load-com)

Example of this approach see HERE where we also where collection more routines into one. But I think that we found different solution than the vla-sendcommand function in the end.

 

Not sure what you mean by this:

and the other remark if other small request command TBM could lead to the Central charge, but overall I'm going to well

 

 

0 Likes