Jump to content

How to Draw Slab Symbol by one click ????


Recommended Posts

Posted

Hope this would help you with it .

 

(defun c:TesT (/ p1 p2 p3 p4 cntr)
;;; Tharwat 06. March 2012 ;;;
;;;    Draw Slab Symbol    ;;;
 (defun CrossLine (a b)
   (entmake
     (list '(0 . "LINE")
           (cons 10 a)
           (cons 11
                 (polar a (angle a b) (- (/ (distance a b) 2.) 0.225))
           )
           (cons 8 "_layer S-SPEC-SLAB")
     )
   )
 )
 (defun _Text (p str)
   (entmake (list '(0 . "TEXT")
                  '(40 . 0.2)
                  (cons 1 str)
                  (cons 10 p)
                  (cons 11 p)
                  (cons 7 (getvar 'textstyle))
                  '(51 . 0.)
                  (cons 8 "_layer S-SPEC-TEXT")
                  '(71 . 0)
                  '(72 . 1)
                  '(73 . 2)
                  '(210 0.0 0.0 1.0)
            )
   )
 )
 (if (and
       (setq p1 (getpoint "\n First corner :"))
       (setq p2 (getcorner p1 "\n Second corner :"))
     )
   (progn
     (setq p3 (list (car p1) (cadr p2) 0.)
           p4 (list (car p2) (cadr p1) 0.)
     )
     (if (> (distance p1 p3) 1.5)
       (progn
         (setq
           cntr (mapcar
                  (function
                    (lambda (first second) (/ (+ first second) 2.))
                  )
                  p1
                  p2
                )
         )
         (CrossLine p1 p2)
         (CrossLine p2 p1)
         (CrossLine p3 p4)
         (CrossLine p4 p3)
         (entmake (list '(0 . "CIRCLE")
                        (cons 10 cntr)
                        '(40 . 0.225)
                        (cons 8 "_layer S-SPEC-SLAB")
                  )
         )
         (_Text cntr "GS")
         (_Text (polar cntr 4.71239 0.4) "+0.20")
       )
       (princ
         "\n *** Diameter of Rectangle is too small must be minimum 1.50 *** "
       )
     )
   )
   (princ)
 )
 (princ)
)

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • git_thailand

    8

  • Tharwat

    4

  • ReMark

    3

  • asos2000

    2

Top Posters In This Topic

Posted Images

Posted
Hope this would help you with it .

 

(defun c:TesT (/ p1 p2 p3 p4 cntr)
;;; Tharwat 06. March 2012 ;;;
;;;    Draw Slab Symbol    ;;;
 (defun CrossLine (a b)
   (entmake
     (list '(0 . "LINE")
           (cons 10 a)
           (cons 11
                 (polar a (angle a b) (- (/ (distance a b) 2.) 0.225))
           )
           (cons 8 "_layer S-SPEC-SLAB")
     )
   )
 )
 (defun _Text (p str)
   (entmake (list '(0 . "TEXT")
                  '(40 . 0.2)
                  (cons 1 str)
                  (cons 10 p)
                  (cons 11 p)
                  (cons 7 (getvar 'textstyle))
                  '(51 . 0.)
                  (cons 8 "_layer S-SPEC-TEXT")
                  '(71 . 0)
                  '(72 . 1)
                  '(73 . 2)
                  '(210 0.0 0.0 1.0)
            )
   )
 )
 (if (and
       (setq p1 (getpoint "\n First corner :"))
       (setq p2 (getcorner p1 "\n Second corner :"))
     )
   (progn
     (setq p3 (list (car p1) (cadr p2) 0.)
           p4 (list (car p2) (cadr p1) 0.)
     )
     (if (> (distance p1 p3) 1.5)
       (progn
         (setq
           cntr (mapcar
                  (function
                    (lambda (first second) (/ (+ first second) 2.))
                  )
                  p1
                  p2
                )
         )
         (CrossLine p1 p2)
         (CrossLine p2 p1)
         (CrossLine p3 p4)
         (CrossLine p4 p3)
         (entmake (list '(0 . "CIRCLE")
                        (cons 10 cntr)
                        '(40 . 0.225)
                        (cons 8 "_layer S-SPEC-SLAB")
                  )
         )
         (_Text cntr "GS")
         (_Text (polar cntr 4.71239 0.4) "+0.20")
       )
       (princ
         "\n *** Diameter of Rectangle is too small must be minimum 1.50 *** "
       )
     )
   )
   (princ)
 )
 (princ)
)

 

thank you. How to add function change text and loop

Posted
thank you. How to add function change text and loop

 

Things like this ..... ?

 

(defun c:TesT (/ p1 p2 str p3 p4 cntr)
;;; Tharwat 07. March 2012 ;;;
;;;    Draw Slab Symbol    ;;;
 (defun CrossLine (a b)
   (entmake
     (list '(0 . "LINE")
           (cons 10 a)
           (cons 11
                 (polar a (angle a b) (- (/ (distance a b) 2.) 0.225))
           )
           (cons 8 "_layer S-SPEC-SLAB")
     )
   )
 )
 (defun _Text (p str)
   (entmake (list '(0 . "TEXT")
                  '(40 . 0.2)
                  (cons 1 str)
                  (cons 10 p)
                  (cons 11 p)
                  (cons 7 (getvar 'textstyle))
                  '(51 . 0.)
                  (cons 8 "_layer S-SPEC-TEXT")
                  '(71 . 0)
                  '(72 . 1)
                  '(73 . 2)
                  '(210 0.0 0.0 1.0)
            )
   )
 )
 (while
   (and
     (setq p1 (getpoint "\n First corner :"))
     (setq p2 (getcorner p1 "\n Second corner :"))
     (not (eq (setq str (getstring t "\n Enter text :")) ""))
   )
    (progn
      (setq p3 (list (car p1) (cadr p2) 0.)
            p4 (list (car p2) (cadr p1) 0.)
      )
      (if (> (distance p1 p3) 1.5)
        (progn
          (setq
            cntr (mapcar
                   (function
                     (lambda (first second) (/ (+ first second) 2.))
                   )
                   p1
                   p2
                 )
          )
          (CrossLine p1 p2)
          (CrossLine p2 p1)
          (CrossLine p3 p4)
          (CrossLine p4 p3)
          (entmake (list '(0 . "CIRCLE")
                         (cons 10 cntr)
                         '(40 . 0.225)
                         (cons 8 "_layer S-SPEC-SLAB")
                   )
          )
          (_Text cntr str)
          (_Text (polar cntr 4.71239 0.4) "+0.20")
        )
        (princ
          "\n *** Diameter of Rectangle is too small must be minimum 1.50 *** "
        )
      )
    )
 )
 (princ)
)

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