Jump to content

Recommended Posts

Posted

Oh this is sad your code is way smaller then mine :D

 

Works well the only things different it the with and the seconds ofsset is suppose to be on color 61 but it think i can figure it out hehe..

 

Now I've been trying to use foreach with what you suggested and i can't make it work all the ways I put it i get errors hehe!

 

I wish I could be that good at writting codes hehe i'm still only a beginner :D

  • Replies 28
  • Created
  • Last Reply

Top Posters In This Topic

  • CadFrank

    14

  • Tharwat

    12

  • Lee Mac

    3

Top Posters In This Topic

Posted Images

Posted

A little bit better , try it .... :)

 

(defun c:MtextFrame (/ *error* _Line _Poly ang e h ht i p p1 p2 p3 p4 p5 p6 p7 p8 ss v)
 (vl-load-com)
;;; Author : Tharwat Al Shoufi 23. Oct. 2012  ;;;
 (if (not acdoc)
   (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
 )
 (defun *error* (x)
   (vla-EndUndoMark acdoc)
   (setvar 'cmdecho 1)
   (princ "\n ...")
   (princ "\n *Cancel*")
 )
 (if (not (tblsearch "LAYER" "-LU SYMBOLE"))
   (vl-cmdf "._-layer"
            "_n"
            "-LU SYMBOLE"
            "_C"
            "90"
            "-LU SYMBOLE"
            ""
   )
 )
 (defun _Line (pt1 pt2)
   (entmakex (list '(0 . "LINE")
                   '(8 . "-LU SYMBOLE")
                   '(62 . 61)
                   (cons 10 pt1)
                   (cons 11 pt2)
             )
   )
 )
 (defun _Poly (po1 po2 po3 po4 w clr)
   (entmakex (list '(0 . "LWPOLYLINE")
                   '(100 . "AcDbEntity")
                   '(100 . "AcDbPolyline")
                   '(90 . 5)
                   '(70 . 1)
                   '(8 . "-LU SYMBOLE")
                   (cons 10 po1)
                   (cons 10 po2)
                   (cons 10 po2)
                   (cons 10 po3)
                   (cons 10 po4)
                   (cons 62 clr)
                   (cons 43 w)
             )
   )
 )

 (if (setq ss (ssget '((0 . "MTEXT") (71 . 1) (72 . 5))))
   (progn (vla-StartUndoMark acdoc)
          (setvar 'cmdecho 0)
          (repeat (setq i (sslength ss))
            (setq e (entget (ssname ss (setq i (1- i)))))
            (mapcar 'set
                    '(p h v ang ht)
                    (list (cdr (assoc 10 e))
                          (cdr (assoc 42 e))
                          (cdr (assoc 43 e))
                          (cdr (assoc 50 e))
                          (cdr (assoc 40 e))
                    )
            )
            (setq p1 (polar (polar p (+ ang pi) (* ht 0.65))
                            (+ ang (/ pi 2.))
                            (* ht 0.65)
                     )
                  p3 (polar (setq p2 (polar p1 ang (+ (* (* ht 0.65) 2.) h)))
                            (+ ang (* pi 1.5))
                            (+ (* (* ht 0.65) 2.) v)
                     )
                  p4 (polar p3 (+ ang pi) (+ (* (* ht 0.65) 2.) h))
                  p5 (polar (polar p1 (+ ang pi) (* ht 0.65))
                            (+ ang (/ pi 2.))
                            (* ht 0.65)
                     )
                  p6 (polar p5 ang (+ (* (* ht 0.65) 4.) h))
                  p7 (polar p6 (+ ang (* pi 1.5)) (+ (* (* ht 0.65) 4.) v))
                  p8 (polar p7 (+ ang pi) (+ (* (* ht 0.65) 4.) h))
            )
            (mapcar '_Line
                    (list p5 p5 p6 p6 p7 p7 p8 p8)
                    (list (polar p5 (+ ang (/ pi 2.)) ht)
                          (polar p5 (+ ang pi) ht)
                          (polar p6 (+ ang (/ pi 2.)) ht)
                          (polar p6 ang ht)
                          (polar p7 ang ht)
                          (polar p7 (+ ang (* pi 1.5)) ht)
                          (polar p8 (+ ang pi) ht)
                          (polar p8 (+ ang (* pi 1.5)) ht)
                    )
            )
            (_Poly p1 p2 p3 p4 (/ ht 3.) 256)
            (_Poly p5 p6 p7 p8 0.0 61)
          )
          (vla-EndUndoMark acdoc)
          (setvar 'cmdecho 1)
   )
 )
 (princ "\n Written by Tharwat Al Shoufi")
 (princ)
)

Posted

Well I've test it and it does this weird frame.

 

Look at the rec circle.

 

Look.jpg

Posted

I think I found out why..

 

  (defun _Poly (po1 po2 po3 po4 w)    
(entmakex (list '(0 . "LWPOLYLINE")                    
'(100 . "AcDbEntity")                    
'(100 . "AcDbPolyline")                    
'(90 . 5)                   
'(70 . 1)                    
'(8 . "-LU SYMBOLE")                    
(cons 10 po1)                    
(cons 10 po2)                     
(cons 10 po2); you have a double                     
(cons 10 po3)                    
(cons 10 po4)                  
(cons 43 w)              
)))

Posted

That's correct , so try it now with rotated mtexts also and see the difference .

 

(defun c:MtextFrame (/    *error*
                    _Line
                    _Poly
                    ang  e
                    h    ht
                    i    p
                    p1   p2
                    p3   p4
                    p5   p6
                    p7   p8
                    ss   v
                   )
 (vl-load-com)
;;; Author : Tharwat Al Shoufi 23. Oct. 2012  ;;;
 (if (not acdoc)
   (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
 )
 (defun *error* (x)
   (vla-EndUndoMark acdoc)
   (setvar 'cmdecho 1)
   (princ "\n ...")
   (princ "\n *Cancel*")
 )
 (if (not (tblsearch "LAYER" "-LU SYMBOLE"))
   (vl-cmdf "._-layer" "_n" "-LU SYMBOLE" "_C" "90" "-LU SYMBOLE" "")
 )
 (defun _Line (pt1 pt2)
   (entmakex (list '(0 . "LINE")
                   '(8 . "-LU SYMBOLE")
                   '(62 . 61)
                   (cons 10 pt1)
                   (cons 11 pt2)
             )
   )
 )
 (defun _Poly (po1 po2 po3 po4 w clr)
   (entmakex (list '(0 . "LWPOLYLINE")
                   '(100 . "AcDbEntity")
                   '(100 . "AcDbPolyline")
                   '(90 . 4)
                   '(70 . 1)
                   '(8 . "-LU SYMBOLE")
                   (cons 10 po1)
                   (cons 10 po2)
                   (cons 10 po3)
                   (cons 10 po4)
                   (cons 62 clr)
                   (cons 43 w)
             )
   )
 )

 (if (setq ss (ssget '((0 . "MTEXT") (71 . 1) (72 . 5))))
   (progn (vla-StartUndoMark acdoc)
          (setvar 'cmdecho 0)
          (repeat (setq i (sslength ss))
            (setq e (entget (ssname ss (setq i (1- i)))))
            (mapcar 'set
                    '(p h v ang ht)
                    (list (cdr (assoc 10 e))
                          (cdr (assoc 42 e))
                          (cdr (assoc 43 e))
                          (cdr (assoc 50 e))
                          (cdr (assoc 40 e))
                    )
            )
            (setq p1 (polar (polar p (+ ang pi) (* ht 0.65))
                            (+ ang (/ pi 2.))
                            (* ht 0.65)
                     )
                  p3 (polar (setq p2 (polar p1 ang (+ (* (* ht 0.65) 2.) h)))
                            (+ ang (* pi 1.5))
                            (+ (* (* ht 0.65) 2.) v)
                     )
                  p4 (polar p3 (+ ang pi) (+ (* (* ht 0.65) 2.) h))
                  p5 (polar (polar p1 (+ ang pi) (* ht 0.65))
                            (+ ang (/ pi 2.))
                            (* ht 0.65)
                     )
                  p6 (polar p5 ang (+ (* (* ht 0.65) 4.) h))
                  p7 (polar p6 (+ ang (* pi 1.5)) (+ (* (* ht 0.65) 4.) v))
                  p8 (polar p7 (+ ang pi) (+ (* (* ht 0.65) 4.) h))
            )
            (mapcar '_Line
                    (list p5 p5 p6 p6 p7 p7 p8 p8)
                    (list (polar p5 (+ ang (/ pi 2.)) ht)
                          (polar p5 (+ ang pi) ht)
                          (polar p6 (+ ang (/ pi 2.)) ht)
                          (polar p6 ang ht)
                          (polar p7 ang ht)
                          (polar p7 (+ ang (* pi 1.5)) ht)
                          (polar p8 (+ ang pi) ht)
                          (polar p8 (+ ang (* pi 1.5)) ht)
                    )
            )
            (_Poly p1 p2 p3 p4 (/ ht 3.) 256)
            (_Poly p5 p6 p7 p8 0.0 61)
          )
          (vla-EndUndoMark acdoc)
          (setvar 'cmdecho 1)
   )
 )
 (princ "\n Written by Tharwat Al Shoufi")
 (princ)
)

Posted

Well now it works like a charm..

 

Any advice for me to learn Autolisp quick?

Posted
Well now it works like a charm..

 

happy to hear that . :)

 

Any advice for me to learn Autolisp quick?

 

Reading and practicing daily to become familiar with functions and to learn more better ways while writing programs .

 

Good luck .

Posted

Well Thanks alot

 

Cheers & Beers !

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