Jump to content

How to continue execution of the routine?


Recommended Posts

Posted

Dear masters.

After setting the UCS "OB" as continue the execution of the routine?

Once completed the cycle, how to reset the previous UCS?

 

;;teknomatika
(defun c:asna (/ hdist vdist divn distseg pti1 pts1 pti2)
(command "ucs" "OB" "pause" "")[color="red"];;The execution is stopping here.[/color]
(setq hdist (getdist "\nHorizontal Distance: "))
(setq vdist(getdist "\nVertical Distance "))
(setq divn (getint "\nDivisons Number: "))
(setq distseg (/ hdist divn))
(setq pti1 (getpoint "\nStart Point: "))
(setq pts1 (list (+(car pti1)distseg)(+(cadr pti1)vdist)(caddr pti1)))
(setq pti2 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1)))
(repeat divn
(command "_.line" "_non" pti1 "_non" pts1 "_non" pti2 "_non""")
(setq pti1 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1)))
(setq pts1 (list (+(car pts1)distseg)(cadr pts1)(caddr pti1)))
(setq pti2 (list (+(car pti1)distseg)(-(cadr pts1)vdist)(caddr pti1)))     
(princ)
);repeat
)
(prompt "\nTo invoque command type ASNA ")

Posted
(command "_.ucs" "_P")

 

Lee,

That, to return to the previous UCS?

But to allow the continuation of routine after setting the UCS "OB"?

 

(command "ucs" "OB" "pause" "");;The execution is stopping here.

Posted

You need to write it like:

(command "_UCS" "_OB" [color=red]pause[/color])

Posted

Tanks.

Ok Works. But it ends with a weird "Command: nil"

Is it so?

 

 

;;teknomatika
(defun c:asna (/ oldclay hdist vdist divn distseg pti1 pts1 pti2)
(setq oldclay (getvar "clayer"))
(command "layer" "new" "asnas" "color" "8" "asnas" "")
(command "layer" "set" "asnas" "")
;;(command "_.ucs" "_P");; Not work
(command "_UCS" "_OB" pause)
(setq hdist (getdist "\nHorizontal Distance: "))
(setq vdist(getdist "\nVertical Distance "))
(setq divn (getint "\nDivisons Number: "))
(setq distseg (/ hdist divn))
(setq pti1 (getpoint "\nStart Point: "))
(setq pts1 (list (+(car pti1)distseg)(+(cadr pti1)vdist)(caddr pti1)))
(setq pti2 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1)))
(repeat divn
(command "_.line" "_non" pti1 "_non" pts1 "_non" pti2 "_non""")
(setq pti1 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1)))
(setq pts1 (list (+(car pts1)distseg)(cadr pts1)(caddr pti1)))
(setq pti2 (list (+(car pti1)distseg)(-(cadr pts1)vdist)(caddr pti1)))     
(princ)
);repeat
(setvar "clayer" oldclay)
(command "_.ucs" "_P")
)
(prompt "\nTo invoque command type ASNA ")

Posted

I did some corrections to your code:

 

  • there is no need to disable AutoOsnap when end the command call,
  • the repeat of that PRINC call is useless
  • in order to allow the routine to exit quietly you need to add a PRINC call as last statement; this will get rid of that final nil.

...
 (command "_.line" "_non" pti1 "_non" pts1 "_non" pti2 [s][color=red]"_non"[/color][/s] "")
 (setq pti1 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1)))
 (setq pts1 (list (+(car pts1)distseg)(cadr pts1)(caddr pti1)))
 (setq pti2 (list (+(car pti1)distseg)(-(cadr pts1)vdist)(caddr pti1)))
 [s][color=red](princ)[/color][/s]
);repeat
(setvar "clayer" oldclay)
(command "_.ucs" "_P")
[color=red] (princ)[/color]
)

Posted
I did some corrections to your code:

 

  • there is no need to disable AutoOsnap when end the command call,
  • the repeat of that PRINC call is useless
  • in order to allow the routine to exit quietly you need to add a PRINC call as last statement; this will get rid of that final nil.

...
 (command "_.line" "_non" pti1 "_non" pts1 "_non" pti2 [s][color=red]"_non"[/color][/s] "")
 (setq pti1 (list (+(car pti1)distseg)(cadr pti1)(caddr pti1)))
 (setq pts1 (list (+(car pts1)distseg)(cadr pts1)(caddr pti1)))
 (setq pti2 (list (+(car pti1)distseg)(-(cadr pts1)vdist)(caddr pti1)))
 [s][color=red](princ)[/color][/s]
);repeat
(setvar "clayer" oldclay)
(command "_.ucs" "_P")
[color=red] (princ)[/color]
)

 

Mircea,

 

tanks for the help!

Posted

teknomatika,

 

Aside: do you understand why the 'nil' was returned to the command-line in your original code?

Posted
teknomatika,

 

Aside: do you understand why the 'nil' was returned to the command-line in your original code?

 

Lee,

I think so.:oops:

For explanation of Mircea, but also because of the fact it was a mistake to my poor location of (Princ) inside the loop.

 

Tanks for the help.

Posted
I think so. :oops:

 

To clarify for you: In your original code, nil is returned to the command-line because the last evaluated expression enclosed by your defun expression is the command expression, and the command function always returns nil (as stated in the documentation).

 

Note this behaviour from the Visual LISP IDE Help Documentation on the defun function:

 

defun

ac.right.gif

Defines a function.

(defun sym ([arguments] [/ variables...]) expr...)

Arguments

 

sym A symbol naming the function.

 

arguments The names of arguments expected by the function.

 

/ variables The names of one or more local variables for the function.

 

expr Any number of AutoLISP expressions to be evaluated when the function executes.

 

Return Values

 

[highlight]The result of the last expression evaluated.[/highlight]

 

This inherent behaviour is intuitive when definining 'subfunctions', for example:

(defun add2 ( x ) (+ x 2))

When called with a numerical argument, the above function will return the result of the last expression evaluated inside the function definition (defun), that is, the call to the + function, returning the supplied argument plus 2:

_$ (add2 5)
7

Note that this is a property of the defun function and hence applies to all functions defined in such a way. Those functions whose symbol name is prefixed with c: are treated in exactly the same way - the c: prefix simply allows the function to be called as a command directly from the command-line.

Posted

Lee,

 

I appreciate the attention and explanation.

Tanks!

Posted

The routine is still pretty basic, but this new version, I solved the problem of UCS with another solution. Basically, an option intended to draw both basis orthogonal mode as parallel lines in rows and not in parallel with angle. Apparently is solved.

 

 

;;by teknomatika 10/2012
;;draw truss lines - variant perpendicular
(defun c:ZIGP (/ nd p1 p2 p3 p4 div1 ang1 div2 ang2 pt1)
(setq oldclay (getvar "clayer"))
(command "layer" "new" "truss" "color" "8" "truss" "")
(command "layer" "set" "truss" "")
(setq nd (getint "\n Nº divisions:"))
(setq p1 (getpoint "\n Specify start point of base line :"))
(setq p2 (getpoint p1 "\n Specify end point of base line :"))
(setq p3 (getpoint "\n Specify start point of top line :"))
(setq p4 (getpoint "\n Specify end point of top line :"))
(setq div1 (/(distance p1 p2)nd))
(setq div2 (/(distance p3 p4)nd))
(setq ang1 (angle p1 p2))
(setq ang2 (angle p3 p4))
(setq pt1 (polar p1 ang1 div1))
(command "_.line" "_non" p1 "_non" p3 "")
(command "_.line" "_non" p3 "_non" pt1 "")
(repeat (- nd 1)
(setq p1 pt1)
(setq p3 (polar p3 ang2 div2))
(setq pt1 (polar p1 ang1 div1))
(command "_.line" "_non" p1 "_non" p3 "")
(command "_.line" "_non" p3 "_non" pt1 "")
);repeat
(command "_.line" "_non" p2 "_non" p4 "")
(setvar "clayer" oldclay)
(princ)
);defun
(prompt "\n Type ZIGP ")
;;;
;;;
;;by teknomatika 10/2012
;;draw truss lines - variant zig-zag
(defun c:ZIGZ (/ nd p1 p2 p3 p4 div1 ang1 div2 ang2 pt1)
(setq oldclay (getvar "clayer"))
(command "layer" "new" "truss" "color" "8" "truss" "")
(command "layer" "set" "truss" "")
(setq nd (getint "\n Nº divisions:"))
(setq p1 (getpoint "\n Specify start point of base line :"))
(setq p2 (getpoint p1 "\n Specify end point of base line :"))
(setq p3 (getpoint "\n Specify start point of top line :"))
(setq p4 (getpoint "\n Specify end point of top line :"))
(setq div1 (/(distance p1 p2)nd))
(setq div2 (/(distance p3 p4)nd))
(setq ang1 (angle p1 p2))
(setq ang2 (angle p3 p4))
(setq pt1 (polar p1 ang1 div1))
(command "_.line" "_non" p3 "_non" p1 "")
(setq p3 (polar p3 ang2 (/ div2 2)))
(command "_.line" "_non" p1 "_non" p3 "")
(command "_.line" "_non" p3 "_non" pt1 "")
(repeat (- nd 1)
(setq p1 pt1)
(setq p3 (polar p3 ang2 div2))
(setq pt1 (polar p1 ang1 div1))
(command "_.line" "_non" p1 "_non" p3 "")
(command "_.line" "_non" p3 "_non" pt1 "")
);repeat
(command "_.line" "_non" p2 "_non" p4 "")
(setvar "clayer" oldclay)
(princ)
);defun
(prompt "\n Type ZIGZ ")

cadtutor_exp_5.jpg

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