autolisp

autolisp

Anonymous
Not applicable
982 Views
5 Replies
Message 1 of 6

autolisp

Anonymous
Not applicable

 Hi i want to create a 2p rectangle with opening symbol inside,

could you  please help me, thanks in advance

 

image-1.JPG

 

 

 

 

0 Likes
Accepted solutions (2)
983 Views
5 Replies
Replies (5)
Message 2 of 6

ВeekeeCZ
Consultant
Consultant
Accepted solution
(vl-load-com)

(defun c:RectangX (/ enl)
  
  (command-s "_.RECTANG")
  (setq enl (entlast))
  (entmake (list (cons 0 "LINE")
		 (cons 10 (vlax-curve-getpointatparam enl 0.))
		 (cons 11 (vlax-curve-getpointatparam enl 2.))
		 (cons 62 1)))
  (entmake (list (cons 0 "LINE")
		 (cons 10 (vlax-curve-getpointatparam enl 1.))
                 (cons 11 (vlax-curve-getpointatparam enl 3.))
		 (cons 62 1)))
  (princ)
  )
Message 3 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

Something I came up with for someone close to 3 years ago....  It doesn't include  the drawing of the rectangle part, but it will put the X part in as many 4-sided closed LWPolylines as you select, all at once.  It also does the X parts on the current Layer, which can be different from that of the selected Polyline(s).  [Should @ВeekeeCZ 's suggestion perhaps put the Lines on a different Layer, rather than give them an override color?]

;|
XinQuad.lsp [command name: XQ]
To draw an X of 2 Lines in a QUADrilateral Polyline.
[Typically to X in rectangles, but will draw Lines across opposite
  vertices of any 4-sided closed LWPolyline, incl. w/ arc segment(s).]
Draws Lines on current Layer with all current Properties.
Works in WCS or any UCS.
Kent Cooper, 19 January 2017
|;

(defun C:XQ (/ pt plss n pl)
  (defun pt (par)
    (trans (vlax-curve-getPointAtParam pl par) 0 1)
  ); defun -- pt
  (if (setq plss (ssget '((0 . "LWPOLYLINE") (90 . 4) (-4 . "&") (70 . 1))))
    (repeat (setq n (sslength plss))
      (setq pl (ssname plss (setq n (1- n))))
      (command
        "_.line" "_none" (pt 0) "_none" (pt 2) ""
        "_.line" "_none" (pt 1) "_none" (pt 3) ""
      ); command
    ); repeat
  ); if
  (princ)
); defun -- C:XQ

(vl-load-com)
(prompt "\nType XQ to draw X Lines in closed Quadrilateral Polyline(s).")
Kent Cooper, AIA
Message 4 of 6

Anonymous
Not applicable

Hi guys, thanks for the help, these are very useful for me.

it saves me a lot of time.

your're the best, number 1!

0 Likes
Message 5 of 6

ВeekeeCZ
Consultant
Consultant

Only one could be the best.

0 Likes
Message 6 of 6

hak_vz
Advisor
Advisor

One late entry

 

(defun c:xrect( / a pts xlst ylst dx dy minx miny )
    (setq pts (list (setq a (getpoint "\nSelect first point")) (getcorner a "\nSelect second point")))
    (setq xlst (mapcar 'car pts) ylst (mapcar 'cadr pts))
    (mapcar 'set '(dx dy) (list (apply '- (mapcar 'abs xlst))(apply '- (mapcar 'abs ylst))))
    (setq minx (apply 'min xlst) miny (apply 'min ylst))
    (mapcar 'set '(dx dy) (mapcar 'abs (list dx dy)))
    (command "rectangle" (list minx miny) (list (+ minx dx) (+ miny dy)))
    (command "_.line"  (list minx miny) (list (+ minx dx) (+ miny dy)) "")
    (command   "_.line" (list (+ minx dx) miny) (list minx (+ miny dy)) "")
    (princ)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes