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

Problem with loop and command

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
manuel.lozanomASTWU
258 Views, 5 Replies

Problem with loop and command

Thank you very much in advance. I have the following code

 

  (defun premier ( /)
        
   
      (setq cnt 0)
      (while (< cnt (length list))

    (if (= 1 ACPV)

      (command "._SemiAutoGenerate" block "" ""  aling "" "" (nth cnt list) "" "" "" )
      )
 

    (setq cnt (+ cnt 1))
    );end while

    
    
      );end defun

note:list is a list of list example ((10 4 5)(5 6 7)(8 9 10)...)

 

that calls a command that does not belong to autocad, but to an external application. My problem is that I have created a loop with while that repeats the command n times, I want that loop to be inside the command or use some type of subroutine. I think it's impossible. thank you so much

5 REPLIES 5
Message 2 of 6

do not use "list" as a variable as its a function.
Also how do you want to define the list? if its from outside the function its better to set it as an argument for your function like that: 

(defun premier (lst /)...)
Message 3 of 6

What exactly do you mean? Where should the loop be?


I want that loop to be inside the command or use some type of subroutine.



Message 4 of 6

i dont know if thats the loop you want and i dont know if this'll work but heres a loop inside a command.

 

(defun premier (lst block acpv align / cnt)
  (setq cnt 0)
  (command "._SemiAutoGenerate" block "" ""  aling "" "") 
  
  (while (< cnt (length lst))
    (if (= 1 ACPV)
      (command (nth cnt lst))
    )
    (setq cnt (1+ cnt))
  );end while
  
  (command "" "" "")
);end defun
Message 5 of 6

thank you very much to all. Let me summarize a bit, the command is not a native AutoCAD command, it calls block which I give it to you before and aling which I give it to you before top and takes it to the nth part which is where there is a list with sublists and each cnt takes an element of They are the same. I want to integrate this into the vomsndo dedoues of block and aling. I'll try your solution and tell you. I thank you and your advice, I am new to mlisp.

Message 6 of 6

Thanks

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report