Author Topic: Ethics on combing 2 lisp routines diff. authors and got a better Background Mask  (Read 8077 times)

0 Members and 1 Guest are viewing this topic.

doggarncity

  • Guest
Hi all
    I have found 2 routines by 2 different authors and want to know if the credits show in the code
can I post the combined with the little bit of my addon to call it a new routine? I have found
one nice Background mask routine that toggles, but didn't have the offset declared and was to big.
Next found a routine I could declare the offset added my settings and combinded the two routines
to make a better one. Is it okay to post that combined and share that works in acad 2009?
authors:
BMask v1.0 January, 2007 ©Timothy Spangler
MT ©Lee Ambrosius Created on: 4/7/2004


Thanks
MJP

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Sure. As long as your giving credit where credit is due, people cant get angry at you. If they didnt want you to use it then they wouldn't have posted it right?

Post away!
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
I would like to see it......   :-P
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

doggarncity

  • Guest
I would like to see it......   :-P

I'm working on it... the only thing I wanted to do to yours is declare/set the mask offset. If you have done
that I'll not go any further and would love to see it. The Offset Mask is to large for me. I found Lee's and it can be
declared in the lisp.
MJP

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
I actually havent done it.  I use it how it is, but you idea sound like a good addition.  I'll look at it this evening and get back to you, if you get done in the meantime post what you have.

ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
I use Lee's routine but I am curious, what don't you like about it.  For me it is too many enters to get to the point of selecting text.  Minor Annoyance that pops into my mind from time to time.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

sourdough

  • Bull Frog
  • Posts: 367
I use Lee's routine but I am curious, what don't you like about it.  For me it is too many enters to get to the point of selecting text.  Minor Annoyance that pops into my mind from time to time.

My biggest problem is that I like the toggle from Tim, but also love the ability in Lee's to keep the mask much closer to the text with a minor edit to code.

MJP
sourdoug/doggarncity for now
LDC 2009/C3D 2010/C3D 2011/C3D 2016

Win 10 64bit

sourdough

  • Bull Frog
  • Posts: 367
I actually havent done it.  I use it how it is, but you idea sound like a good addition.  I'll look at it this evening and get back to you, if you get done in the meantime post what you have.



Okay here is a go at a hybrid of Vlisp/lisp that will work so keep an open mind.

Code: [Select]
;;; command is : BM
;;; This is a hybrid of code from 2 authors (below) and modified by Michael J. Perry from Raleigh, NC to 3-17-09
;;; Overcome the background mask offset of Mtext. I have noted in code where to make the change
;;; I also included a toggle at the end of masking to flip one textmasking off. Would love to loop it till done,
;;; this is what I could combine in 2 days to get it to work. Feel free to complete this if someone can
;;; add the loop in or more.
;;;    BMASK.lsp v1.0
;;;
;;;    Copyright © January, 2007
;;;    Timothy G. Spangler
;;;
;;;    Permission to use, copy, modify, and distribute this software
;;;    for any purpose and without fee is hereby granted, provided
;;;    that the above copyright notice appears in all copies and
;;;    that both that copyright notice and the limited warranty and
;;;    restricted rights notice below appear in all supporting
;;;    documentation.
;;;
;;;    THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
;;;    WARRANTY. ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
;;;    PURPOSE AND OF MERCHANTIBILITY ARE HEREBY DISCLAIMED BY THE
;;;    PROGRAMMER.

;; Written by: Lee Ambrosius
;; Created on: 4/7/2004

;; This program allows you to add Background Mask to several Mtext objects

;; at one time instead of using the Mtext editor for each object or the Properties Palette.

;; The Properties Palette in 2005 doesn't allow you to set Background Color or Border Offset.

(defun c:bm ( / kWordBackgroundMaskCurrent dOffsetCurrent ssMtext dxf90 dxf63 dxf45 dxf441 TextObj TextEntList vlText vlFill *error*)
(setvar "users1" "")
  (prompt "\nSelect Multiple/Single Mtext to Mask or 'Enter to Toggle Off")

    (setq kWordBackgroundMask "Background")
   

  (if (= kWordBackgroundMask nil)
    (setq kWordBackgroundMask kWordBackgroundMaskCurrent)
  )


  (cond ((= kWordBackgroundMask "Color")
            (if (or (= maskClr nil) (/= (type maskClr) 'LIST))
               (setq maskClr (acad_truecolorcli 1))
               (if (= (assoc 420 maskClr) nil)

                 (setq maskClr (acad_truecolorcli (cdr (assoc 62 maskClr))))
                 (setq maskClr (acad_truecolorcli (assoc 420 maskClr)))
               )
            )
        )
        ((= kWordBackgroundMask "Background")(setq maskClr 256))

        ((= kWordBackgroundMask "None")(setq maskClr 0 dOffset 1.0))
  )

  (if (/= maskClr nil)
    (progn
      (if (/= kWordBackgroundMask "None")
        (progn
          (setq dOffsetCurrent dOffset)


          (if (= dOffsetCurrent nil)
            (setq dOffset 1.0 dOffsetCurrent 1.0)
            (setq dOffsetCurrent dOffset)
          )

          (setq dOffset 1.15);  ********** change Offset masking here eg 1=text frame
   
          (if (= dOffset nil)

            (setq dOffset dOffsetCurrent)
          )

          (if (> dOffset 5)(setq dOffset nil))
          (if (< dOffset 1)(setq dOffset nil))

          (while (= dOffset nil)
            (setq dOffset (getreal (strcat "\nSpecify border offset factor: <" (rtos dOffsetCurrent 2 3) ">: ")))

 
            (if (> dOffset 5)(setq dOffset nil))
            (if (< dOffset 1)(setq dOffset nil))
          )
        )
        (if (= dOffset nil)
          (setq dOffset 1.0)
        )
      )


      (if (setq ssMtext (ssget (list (cons 0 "MTEXT"))))

        (progn
          (cond ((= kWordBackgroundMask "None")
                    (setq mask_list (list (cons 90 2)(cons 63 0)(cons 45 dOffset)(cons 441 0))

                          dxf90 2
                          dxf63 nil
                          dxf45 nil
                          dxf441 nil
                    )
                )
                ((and (= kWordBackgroundMask "Color")(/= (assoc 420 maskClr) nil))

                    (setq mask_list (list (cons 90 1)(cons 63 1)(cons 421 (cdr (assoc 420 maskClr)))(cons 45 dOffset)(cons 441 (cdr (assoc 420 maskClr))))
                          dxf90 1
                          dxf63 2

                          dxf45 dOffset
                          dxf441 (cdr (assoc 420 maskClr))
                    )
                )
                ((and (= kWordBackgroundMask "Color")(= (assoc 420 maskClr) nil))

                    (setq mask_list (list (cons 90 1)(cons 63 (cdr (assoc 62 maskClr)))(cons 45 dOffset)(cons 441 2146608))
                          dxf90 1
                          dxf63 (cdr (assoc 62 maskClr))

                          dxf45 dOffset
                          dxf441 nil
                    )
                )
                ((= kWordBackgroundMask "Background")
                    (setq mask_list (list (cons 90 3)(cons 63 3)(cons 45 dOffset)(cons 441 0))

                          dxf90 3
                          dxf63 256
                          dxf45 dOffset
                          dxf441 0
                    )
                )
          )


          (setq emax (sslength ssMtext)
                sscount 0
          )

          (while (< sscount emax)
            (setq EN (entget (ssname ssMtext sscount))
  tempEN nil)

            (if (/= dxf90 nil)

              (progn
                (if (/= (assoc 90 EN) nil)
                  (setq EN (subst (cons 90 dxf90) (assoc 90 EN) EN))
                  (setq EN (append EN (list (cons 90 dxf90))))
                )

              )
              (progn
                (setq CNT 0
                      nMembers (member (assoc 90 EN) EN))

                (if (= nMembers nil)
                  (setq nMembers 0)
  (setq nMembers (length nMembers))

)
                (repeat (- (length EN) nMembers)
                  (setq tempEN (append tempEN (list (nth cnt EN))))
                  (setq CNT (1+ CNT))
                )

(if (> nMembers 0)

  (progn
    (setq CNT 1)
                    (repeat (- nMembers 1)
                      (setq tempEN (append tempEN (list (nth cnt (member (assoc 90 EN) EN)))))
                      (setq CNT (1+ CNT))

    )
  )
                )
                (setq EN tempEN
      tempEN nil)
              )
            )

   
            (if (/= dxf63 nil)
              (progn
                (if (/= (assoc 63 EN) nil)

                  (setq EN (subst (cons 63 dxf63) (assoc 63 EN) EN))
                  (setq EN (append EN (list (cons 63 dxf63))))
                )
              )
              (progn
                (setq CNT 0

                      nMembers (member (assoc 63 EN) EN))

                (if (= nMembers nil)
                  (setq nMembers 0)
  (setq nMembers (length nMembers))
)
                (repeat (- (length EN) nMembers)

                  (setq tempEN (append tempEN (list (nth cnt EN))))
                  (setq CNT (1+ CNT))
                )

(if (> nMembers 0)
  (progn
    (setq CNT 1)
                    (repeat (- nMembers 1)

                      (setq tempEN (append tempEN (list (nth cnt (member (assoc 63 EN) EN)))))
                      (setq CNT (1+ CNT))
    )
  )
                )
                (setq EN tempEN
      tempEN nil)

              )
            )

            (if (/= dxf45 nil)
              (progn
                (if (/= (assoc 45 EN) nil)
                  (setq EN (subst (cons 45 dxf45) (assoc 45 EN) EN))
                  (setq EN (append EN (list (cons 45 dxf45))))

                )
              )
              (progn
                (setq CNT 0
                      nMembers (member (assoc 45 EN) EN))

                (if (= nMembers nil)
                  (setq nMembers 0)

  (setq nMembers (length nMembers))
)
                (repeat (- (length EN) nMembers)
                  (setq tempEN (append tempEN (list (nth cnt EN))))
                  (setq CNT (1+ CNT))
                )


(if (> nMembers 0)
  (progn
    (setq CNT 1)
                    (repeat (- nMembers 1)
                      (setq tempEN (append tempEN (list (nth cnt (member (assoc 45 EN) EN)))))
                      (setq CNT (1+ CNT))

    )
  )
                )
                (setq EN tempEN
      tempEN nil)
              )
            )

            (if (/= dxf441 nil)
              (progn
                (if (/= (assoc 441 EN) nil)

                  (setq EN (subst (cons 441 dxf441) (assoc 441 EN) EN))
                  (setq EN (append EN (list (cons 441 dxf441))))
                )
              )
              (progn
                (setq CNT 0

                      nMembers (member (assoc 441 EN) EN))

                (if (= nMembers nil)
                  (setq nMembers 0)
  (setq nMembers (length nMembers))
)
                (repeat (- (length EN) nMembers)

                  (setq tempEN (append tempEN (list (nth cnt EN))))
                  (setq CNT (1+ CNT))
                )

(if (> nMembers 0)
  (progn
    (setq CNT 1)
                    (repeat (- nMembers 1)

                      (setq tempEN (append tempEN (list (nth cnt (member (assoc 441 EN) EN)))))
                      (setq CNT (1+ CNT))
    )
  )
                )
                (setq EN tempEN)

              )
     
            )

            (entmod EN)
            (setq sscount (1+ sscount))
          )
        )
      )
    )
  )
  (command "draworder" "p" "" "front")
 (Princ "\nThe Masking is complete.")
 ;;; Begin Error Handler -------------------------------------------------
  (defun *error* (MSG)
 
  (if (not (member MSG '("Function cancelled" "quit / exit abort")))
  (princ (strcat "\n*** Program Ended: "))
  (princ "\n... Program Cancelled ...")
  )
  (while (< 0 (getvar "cmdactive"))
  (command)
  )
  (setvar "CMDECHO" OldCmdEcho)
)
;; Set variables
(setq OldCmdEcho (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
 (vl-load-com)
 ;; Select object
  ;(while(null(setq TextObj(car(entsel "\nToggle MTEXT Mask: "))))
  ;(princ " \nNothing Selected...Try Again ")
  ;)
 
  (setq TextObj(car(entsel "\nToggle MTEXT Mask: ")))
  ;; Get text entity list
  (setq TextEntList (entget TextObj))
 
  ;; Check for MTEXT
  (if (not (= (cdr (assoc 0 TextEntList)) "MTEXT"))
  (progn
  (alert "Selected entity is not MTEXT")
  ;; Reset variables
  (setvar "CMDECHO" OldCmdEcho)
  ;; Restart the program
  (C:BM)
  )
)
 (setq TextEntList (entget TextObj))
 ;; Create activeX text
  (setq vlText (vlax-ename->vla-object TextObj))
  ;(c:mtt)
  ;; Check for background fill
  (setq vlFill (vlax-get-property vlText 'backgroundfill))
 
  ;; If no background fill exsists
  (if (= vlFill :vlax-false)
  (progn
  ;; Set background fill for text
  (vlax-put-property vlText 'backgroundfill :vlax-true)
  (princ "\n Background fill applied")
  )
  (progn
  ;; Set background fill for text
 
  (vlax-put-property vlText 'backgroundfill :vlax-false)
  (princ "\n Background fill removed")
  )
  )
 
  ;; Set the draworder to bring text front
(command "draworder" TextObj "" "front")
;; Reset variables
(setvar "CMDECHO" OldCmdEcho)
(princ)
;;;
;;; Echos to the command line
;(princ "\n BMask v1.0 ©Timothy Spangler, \n  January, 2007....loaded.")
(terpri)
;(princ "C:BM")
(print)
;;; End echo

 (princ)
)

;(prompt "\nType MT to run the command")
(princ)



Hope this helps some who have fought the border offset Dilemma in Mtext

MJP
sourdoug
« Last Edit: March 17, 2009, 01:24:46 PM by sourdoug »
LDC 2009/C3D 2010/C3D 2011/C3D 2016

Win 10 64bit

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Okay here is a go at a hybrid of Vlisp/lisp that will work so keep an open mind.

Hope this helps some who have fought the border offset Dilemma in Mtext

MJP
sourdoug
Okay I like it, the only thing I would suggest is to allow multiple selection of text when wanting to toggle off the mask.  I can make multiple section for toggling it on but not off.  I could be screwing something up though.  I have been known to do that.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

sourdough

  • Bull Frog
  • Posts: 367
Okay here is a go at a hybrid of Vlisp/lisp that will work so keep an open mind.

Hope this helps some who have fought the border offset Dilemma in Mtext

MJP
sourdoug
Okay I like it, the only thing I would suggest is to allow multiple selection of text when wanting to toggle off the mask.  I can make multiple section for toggling it on but not off.  I could be screwing something up though.  I have been known to do that.

Hey if you or someone else can get it I'll really be doing a Happy Dance. I get so wrapped up when I get started
on a project like this. Just wish I had the knowledge to do it all.

Thanks
MJP
Mike
LDC 2009/C3D 2010/C3D 2011/C3D 2016

Win 10 64bit

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Ive looked at 60 or so lines so far and i have quite a few comments. All being that after 63 lines the code does nothing more then set and evaluate and reevaluate variables with no chance to alter those variables from the end user (so why evaluate and reevaluate if nothing can be changed?)

I only have a few minutes left on lunch so i will see how far i get. ...maybe we can do a re-write on this for ya.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

sourdough

  • Bull Frog
  • Posts: 367
Ive looked at 60 or so lines so far and i have quite a few comments. All being that after 63 lines the code does nothing more then set and evaluate and reevaluate variables with no chance to alter those variables from the end user (so why evaluate and reevaluate if nothing can be changed?)

I only have a few minutes left on lunch so i will see how far i get. ...maybe we can do a re-write on this for ya.

Wow, that would be a GodSend if you could. I'm not that much of a programmer but can organize thoughts
on how to and by working my imagination come up with the what if and see if it works. This time it did but not
the right way for sure. I have seen hundreds of posts on this. Who knows maybe Autodesk will add it as a variable to
do a textmask offset that is global. I hope anyway, but till then this works a little bit. I highly respect the work
that was done by the original authors and hope they might want to take it to the next progression.

MJP
Mike
LDC 2009/C3D 2010/C3D 2011/C3D 2016

Win 10 64bit

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Want to learn?

We can do this together if you want. I ask questions, you give answers. I ask you questions i already know the answer to and you look them up (learn) You ask questions and i give answers to...we code this *together*
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

sourdough

  • Bull Frog
  • Posts: 367
Want to learn?

We can do this together if you want. I ask questions, you give answers. I ask you questions i already know the answer to and you look them up (learn) You ask questions and i give answers to...we code this *together*


sounds good always up for a good programming challenge.

MJP
Mike
LDC 2009/C3D 2010/C3D 2011/C3D 2016

Win 10 64bit

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Do you have a directory on your computer where you keep all your lisp's? If not, make one. Mine is in
"My Documents\Programing\AutoLisp" But you can make it where ever you want.

Then go grab this program:
[ http://www.theswamp.org/index.php?topic=26914.0 ]

Unzip and take the exe from the bin directory and put in your programing directory (mine is located here: "My Documents\Programing\AutoLisp") You can trash the rest if you want, all that is left is the manual and the source code; you dont need that.

next double click the exe and a new directory will be created for you called "lsp_proj" rename it to what (What do you want to call this program)?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org