+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Senior Member
    Discipline
    Construction
    wimal's Discipline Details
    Occupation
    cadoperator
    Discipline
    Construction
    Using
    AutoCAD 2016
    Join Date
    Oct 2011
    Location
    sri lanka
    Posts
    488

    Default Single Xline by lisp

    Registered forum members do not see this ad.

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

  2. #2
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    835

    Default

    It's easy to not use a command call:
    Code:
    (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)
    )

  3. #3
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,531

    Default

    You might also find this custom xline program useful.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  4. #4
    Senior Member
    Discipline
    Construction
    wimal's Discipline Details
    Occupation
    cadoperator
    Discipline
    Construction
    Using
    AutoCAD 2016
    Join Date
    Oct 2011
    Location
    sri lanka
    Posts
    488

    Default

    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.

  5. #5
    Super Member
    Using
    not applicable
    Join Date
    Jun 2016
    Posts
    669

    Default

    Code:
    (command "_.xline" "_horizontal" pause "")
    (getvar 'lastpoint)
    BricsCAD 18

  6. #6
    Super Member hanhphuc's Avatar
    Using
    AutoCAD 2007
    Join Date
    Apr 2013
    Location
    Happy Garden
    Posts
    655

    Default

    Quote Originally Posted by wimal View Post
    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?
    Code:
        (setvar 'polarmode 1 )
        (and
        (setq p1 (getpoint "\nSpecify 1st point.. ")) 
        (setq p2 (getpoint p1 "Specify 2nd point.. "))
    	 (apply 'vla-AddXline
    		(cons msps
    		      (mapcar ''((x) (vlax-3d-point (trans x 1 0))) (list p1 p2))
    		      ) 
    		)
        )
    _$ ( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" )
    ; error: too many arguments

  7. #7
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,443

    Default

    Heres another way, using grread and LM:grsnap -

    Code:
    ; 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

  8. #8
    Super Member hanhphuc's Avatar
    Using
    AutoCAD 2007
    Join Date
    Apr 2013
    Location
    Happy Garden
    Posts
    655

    Default

    my $0.02 setvar snapang <angle by grread>
    with cursorsize 100
    _$ ( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" )
    ; error: too many arguments

  9. #9
    Senior Member
    Discipline
    Construction
    wimal's Discipline Details
    Occupation
    cadoperator
    Discipline
    Construction
    Using
    AutoCAD 2016
    Join Date
    Oct 2011
    Location
    sri lanka
    Posts
    488

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by hanhphuc View Post
    my $0.02 setvar snapang <angle by grread>
    with cursorsize 100
    Yes cursor setting is better .

Similar Threads

  1. LISP to get length of single line
    By martyn3200 in forum AutoLISP, Visual LISP & DCL
    Replies: 14
    Last Post: 6th Mar 2015, 07:22 am
  2. using layer with xline in lisp
    By nicolas in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 29th Jul 2010, 11:41 am
  3. Need a LISP function to draw an XLine on a certain layer..
    By f700es in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 11th Jun 2010, 02:24 am
  4. xline to always be red????
    By MikeP in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 13th Apr 2009, 05:36 pm
  5. xline>ang
    By fostertom in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 6
    Last Post: 12th Aug 2008, 10:25 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts