Jump to content

Level zero lisp routine


elfert

Recommended Posts

Hello i found this:

 

http://cad-notes.com/2010/12/autolisp-exercise-using-block-and-conditional-if/

 

And i modified it some of my needs, but i can't make the osnap endpoint and intersection function to work at the line (setvar "OSMODE" 33), why?

 

;;Level0 put in level arrow in level 0 in different direktions.
(defun c:Level0 (/ oldcmdecho oldosnap cnglobalscale labelposition levelarrowtype y x zerolevelposition y1 x1)
;;setting up before the real work is going on
(setq oldcmdecho (getvar "cmdecho"))
(setq oldosnap   (getvar "osmode"))
(setvar "cmdecho" 0)
;;checking the scale
(if (= cnglobalscale nil) ; this will check if user already has defined the drawing scale
(setq cnglobalscale (getreal "\nSet Global Scale for CN Annotation <1/1>: "))
)
(if (= cnglobalscale nil) ; this will check if the user choose default value
(setq cnglobalscale 1)
)
(initget 1)
(while (setq labelposition (getpoint "\nPick Label Position for zerolevel: "))
(setvar "OSMODE" 33)
(setq levelarrowtype (getpoint "\nPick Direction of level arrow"))
(setvar "OSMODE" 0)
;;setting up the zerolevel position
(setq y 0)
(setq x (car labelposition))
(setq zerolevelposition (list x y)) 
;;getting direction on level arrow
(setq y1 (cadr levelarrowtype))
(setq x1 (car levelarrowtype))
;;Labelling the level
(setq label "%%p 0.00")
;;setting conditions
(cond ((and(>= y1 0) (> x1 x)) (command "_-insert" "kote3" zerolevelposition cnglobalscale cnglobalscale 0 label))  
     ((and(<= y1 0) (> x1 x)) (command "_-insert" "kote4" zerolevelposition cnglobalscale cnglobalscale 0 label))
     ((and(>= y1 0) (< x1 x)) (command "_-insert" "kote1" zerolevelposition cnglobalscale cnglobalscale 0 label))
     ((and(<= y1 0) (< x1 x)) (command "_-insert" "kote2" zerolevelposition cnglobalscale cnglobalscale 0 label))
)
(setvar "osmode" oldosnap)
(setvar "cmdecho" oldcmdecho)
(princ)
)
)

 

Thx in advance

Link to comment
Share on other sites

Not sure what you mean though :unsure:

its either you wrap both getpoint prompt on the while condtion with (setvar 'osmode 33) then set it to 0 after after picking the points

 

(while [color=blue][b](progn[/b][/color]
[b][color=blue]      (setvar "OSMODE" 33)      [/color][/b]
[b][color=blue]      (setq labelposition (getpoint "\nPick Label Position for zerolevel: "))[/color][/b]
[b][color=blue]      (setq levelarrowtype (getpoint labelposition "\nPick Direction of level arrow")))[/color][/b]
(setvar "OSMODE" 0)
.....   

 

or leave the osmode setting as it is and just add "_non" within the call for command "insert"

 

(command "_-insert" "kote3" [color=blue][b]"_non"[/b][/color] zerolevelposition cnglobalscale cnglobalscale 0 label)

Edited by pBe
Link to comment
Share on other sites

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