Jump to content

Single Xline by lisp


wimal

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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