Jump to content
wimal

Single Xline by lisp

Recommended Posts

wimal

(command "xline""H")

I need draw a single xline through a selected point on the screen.

And find the coordinates of picked point.

The above code is working , but does not stop after inserting one xline.

Share this post


Link to post
Share on other sites
ronjonp

It's easy to not use a command call:

(defun c:foo (/ p)
 (if (setq p (getpoint "\Pick a point: "))
   (entmakex (list '(0 . "XLINE")
	   '(100 . "AcDbEntity")
	   '(67 . 0)
	   '(8 . "XLINE")
	   '(100 . "AcDbXline")
	   (cons 10 p)
	   '(11 1.0 0.0 0.0)
     )
   )
 )
 (princ)
)

Share this post


Link to post
Share on other sites
wimal

Thanks for both of you providing the codes.But I need to display the xline before the point picking.Point to be decided helping the xline.

Share this post


Link to post
Share on other sites
Roy_043
(command "_.xline" "_horizontal" pause "")
(getvar 'lastpoint)

Share this post


Link to post
Share on other sites
hanhphuc
Thanks for both of you providing the codes.But I need to display the xline before the point picking.Point to be decided helping the xline.

 

maybe rubber band helps?

   (setvar 'polarmode 1 )
   (and
   (setq p1 (getpoint "\nSpecify 1st point.. ")) 
   (setq p2 (getpoint [color="red"]p1[/color] "Specify 2nd point.. "))
 (apply 'vla-AddXline
	(cons msps
	      (mapcar ''((x) (vlax-3d-point (trans x 1 0))) (list p1 p2))
	      ) 
	)
   )

Share this post


Link to post
Share on other sites
Grrr

Heres another way, using grread and LM:grsnap -

 

; Vertical/Horizontal XLINE demo
; Requires:
; http://www.lee-mac.com/grsnap.html
(defun C:test ( / *error* )
 
 (defun *error* ( m )
   (redraw)
   (and m (princ m)) (princ)
 ); defun *error*
 
 (cond
   ( (not LM:grsnap:snapfunction) (alert "\nPlease define 'LM:grsnap:snapfunction'") )
   ( 
     (
       (lambda ( / osf osm a1 a2 vec s g k v d )
         '(84 104 105 115 32 100 101 109 111 32 119 114 105 116 116 101 110 32 98 121 32 71 114 114 114 33 32 58 41)
         (setq osf (LM:grsnap:snapfunction))
         (setq osm (getvar 'osmode))
         (mapcar 'set '(a1 a2 vec) '(0 1. (11 1.0 0.0 0.0)))
         (princ "\nSpecify point for the xline [V]ertical: ")
         (while (not s) (mapcar 'set '(k v) (setq g (grread t 15 0)))
           (cond
             ( (or (eq s '(2 13)) (= 25 k))
               (setq s t)
             )
             ( (= k 5) 
               (setq d (* 3 (getvar 'viewsize)))
               (redraw)
               (setq v (osf (cadr g) osm))
               (grdraw (polar v (* a1 PI) d) (polar v (* a2 PI) d) 1 3)
             )
             ( (= k 3)
               (entmakex
                 (append
                   '( (0 . "XLINE") (100 . "AcDbEntity") (67 . 0) (100 . "AcDbXline") )
                   (list (cons 10 (trans (osf (cadr g) osm) 1 0)))
                   (list vec)
                 )
               ); entmakex
               (setq s t)
             )
             ( (and (= k 2) (member v '(86 118)))
               (princ "\nSpecify point for the xline [H]orizontal: ")
               (mapcar 'set '(a1 a2 vec) '(0.5 1.5 (11 0.0 1.0 0.0)))
             )
             ( (and (= k 2) (member v '(72 104)))
               (princ "\nSpecify point for the xline [V]ertical: ")
               (mapcar 'set '(a1 a2 vec) '(0 1. (11 1.0 0.0 0.0)))
             )
           ); cond
         ); while
       ); lambda
     )
   )
 ); cond
 (*error* nil) (princ)
); defun

Share this post


Link to post
Share on other sites
hanhphuc

my $0.02 setvar snapang

with cursorsize 100

:)

Share this post


Link to post
Share on other sites
wimal
my $0.02 setvar snapang

with cursorsize 100

:)

Yes cursor setting is better .

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×