TheSwamp

CAD Forums => CAD General => Topic started by: ELOQUINTET on June 08, 2004, 11:38:52 AM

Title: need help
Post by: ELOQUINTET on June 08, 2004, 11:38:52 AM
i've been assigned some as built drawings and am looking for an easy way to remove vif from all dimensions in a drawing. anybody have something that would do the job. thanks in advance
Title: need help
Post by: Jeff_M on June 08, 2004, 12:04:11 PM
Sure, here's a lisp that does this. You can change the text to search for/replace with to whatever suits your needs. The routine is case sensitive so if your dimensions actually have VIF you will need to adjust it.

Code: [Select]

(defun c:del_vif(/ str ss)
  (vl-load-com)
  (and (ssget "X" '((0 . "*DIM*")));get all dimension objects
       (setq ss (vla-get-activeselectionset
 (vla-get-activedocument
   (vlax-get-acad-object))));use ActiveX ss
       (vlax-for x ss
(if (wcmatch (setq str (vla-get-textoverride x)) "*vif*");if it matches this string
  (vla-put-textoverride x (vl-string-subst "" "vif" str));replace it with empty string
  )
)
       )
  (princ);exit quietly
  )


Jeff
Title: need help
Post by: ELOQUINTET on June 08, 2004, 12:20:25 PM
thanks jeff works like a charm a real timesaver appreciate it  :wink:
Title: one problem...
Post by: ELOQUINTET on June 08, 2004, 01:04:06 PM
how do i modify this to delete multiple formats. example: i always put V.I.F. but some people put (VIF) some put vif etc. etc. how can i encorporate all the formats so i can be assured there will be no vif on the drawing?

Code: [Select]
   (if (wcmatch (setq str (vla-get-textoverride x)) "*V.I.F.*");if it matches this string
      (vla-put-textoverride x (vl-string-subst "" "V.I.F." str));replace it with empty string
Title: need help
Post by: Jeff_M on June 08, 2004, 01:36:06 PM
This should do it. Replace the entire (vlax-for ) loop with this.
Code: [Select]

(vlax-for x ss
(cond ((wcmatch (setq str (vla-get-textoverride x)) "*vif*")
(vla-put-textoverride x (vl-string-subst "" "vif" str))
)
      ((wcmatch (setq str (vla-get-textoverride x)) "*v.i.f.*")
(vla-put-textoverride x (vl-string-subst "" "v.i.f." str))
)
      ((wcmatch (setq str (vla-get-textoverride x)) "*VIF*")
(vla-put-textoverride x (vl-string-subst "" "VIF" str))
)
      ((wcmatch (setq str (vla-get-textoverride x)) "*V.I.F.*")
(vla-put-textoverride x (vl-string-subst "" "V.I.F." str))
)
      ((wcmatch (setq str (vla-get-textoverride x)) "*(VIF)*")
(vla-put-textoverride x (vl-string-subst "" "(VIF)" str))
)
  )
)


Jeff
Title: need help
Post by: ELOQUINTET on June 08, 2004, 03:08:29 PM
jeff something wrong here's what i get when apploading:

; error: malformed list on input
Title: need help
Post by: CAB on June 08, 2004, 03:18:25 PM
Jeff,
Could it be done this way?

Code: [Select]
(vlax-for x ss
  (mapcar '(lambda (ms)
           (if (wcmatch (setq str (vla-get-textoverride x)) ms)
                    (vla-put-textoverride x (vl-string-subst "" ms str))
                      ))
        '("vif" "VIF" "v.i.f." "V.I.F." "(VIF)"))
)
Title: need help
Post by: ELOQUINTET on June 08, 2004, 04:06:45 PM
so here's what i've got now but am still getting the same message. any of you experts see what's goin on, and could inform me pllllllease

Code: [Select]
(defun c:del_vif(/ str ss)
  (vl-load-com)
  (and (ssget "X" '((0 . "*DIM*")));get all dimension objects
       (setq ss (vla-get-activeselectionset
        (vla-get-activedocument
          (vlax-get-acad-object))));use ActiveX ss
(vlax-for x ss
  (mapcar '(lambda (ms)
           (if (wcmatch (setq str (vla-get-textoverride x)) ms)
                    (vla-put-textoverride x (vl-string-subst "" ms str))
                      ))
        '("vif" "VIF" "v.i.f." "V.I.F." "(VIF)"))
)
  (princ);exit quietly
  )
Title: need help
Post by: CAB on June 08, 2004, 04:17:42 PM
dan,
use this..  I was just messing around with options.

Code: [Select]
(defun c:del_vif (/ str ss)
  (vl-load-com)
  (and (ssget "X" '((0 . "*DIM*"))) ;get all dimension objects
       (setq ss (vla-get-activeselectionset
                  (vla-get-activedocument
                    (vlax-get-acad-object)
                  )
                )
       ) ;use ActiveX ss
       (vlax-for x ss
         (cond ((wcmatch (setq str (vla-get-textoverride x)) "*vif*")
                (vla-put-textoverride x (vl-string-subst "" "vif" str))
               )
               ((wcmatch (setq str (vla-get-textoverride x)) "*v.i.f.*")
                (vla-put-textoverride x (vl-string-subst "" "v.i.f." str))
               )
               ((wcmatch (setq str (vla-get-textoverride x)) "*VIF*")
                (vla-put-textoverride x (vl-string-subst "" "VIF" str))
               )
               ((wcmatch (setq str (vla-get-textoverride x)) "*V.I.F.*")
                (vla-put-textoverride x (vl-string-subst "" "V.I.F." str))
               )
               ((wcmatch (setq str (vla-get-textoverride x)) "*(VIF)*")
                (vla-put-textoverride x (vl-string-subst "" "(VIF)" str))
               )
         )
       )

  )
  (princ) ;exit quietly
)
Title: need help
Post by: ELOQUINTET on June 08, 2004, 04:44:01 PM
mmm doesn't quite work cab. for some reason if it reads as 47" (VIF) when changed it reads as 47" (). damn brackets urrrrgh :twisted:
Title: need help
Post by: CAB on June 08, 2004, 05:01:06 PM
Revised:
Code: [Select]
(defun c:del_vif (/ str ss)
  (vl-load-com)
  (and (ssget "X" '((0 . "*DIM*"))) ;get all dimension objects
       (setq ss (vla-get-activeselectionset
                  (vla-get-activedocument
                    (vlax-get-acad-object)
                  )
                )
       ) ;use ActiveX ss
       (vlax-for x ss
         (cond ((wcmatch (setq str (vla-get-textoverride x)) "*vif*")
                (vla-put-textoverride x (vl-string-subst "" "vif" str))
               )
               ((wcmatch (setq str (vla-get-textoverride x)) "*v.i.f.*")
                (vla-put-textoverride x (vl-string-subst "" "v.i.f." str))
               )
               ((wcmatch (setq str (vla-get-textoverride x)) "*V.I.F.*")
                (vla-put-textoverride x (vl-string-subst "" "V.I.F." str))
               )
               ((wcmatch (setq str (vla-get-textoverride x)) "*(VIF)*")
                (vla-put-textoverride x (vl-string-subst "" "(VIF)" str))
               )
               ((wcmatch (setq str (vla-get-textoverride x)) "*VIF*")
                (vla-put-textoverride x (vl-string-subst "" "VIF" str))
               )
         )
       )

  )
  (princ) ;exit quietly
)
Title: need help
Post by: ELOQUINTET on June 09, 2004, 08:15:49 AM
works great now cab
Title: need help
Post by: ELOQUINTET on June 10, 2004, 10:15:05 AM
i just encountered another problem. i also have to get rid of any plus minus symbols. i tried putting this in the code but no go. heeeeelp please

[/code]               ((wcmatch (setq str (vla-get-textoverride x)) "*%%p*")
                (vla-put-textoverride x (vl-string-subst "" "%%p" str))
Code: [Select]
Title: need help
Post by: CAB on June 10, 2004, 10:32:08 AM
Code: [Select]
(defun c:del_vif (/ str ss)
  (vl-load-com)
  (and (ssget "X" '((0 . "*DIM*"))) ;get all dimension objects
       (setq ss (vla-get-activeselectionset
                  (vla-get-activedocument
                    (vlax-get-acad-object)
                  )
                )
       ) ;use ActiveX ss
       (vlax-for x ss
         (cond ((wcmatch (setq str (vla-get-textoverride x)) "*vif*")
                (vla-put-textoverride x (vl-string-subst "" "vif" str))
               )
               ((wcmatch (setq str (vla-get-textoverride x)) "*v.i.f.*")
                (vla-put-textoverride x (vl-string-subst "" "v.i.f." str))
               )
               ((wcmatch (setq str (vla-get-textoverride x)) "*V.I.F.*")
                (vla-put-textoverride x (vl-string-subst "" "V.I.F." str))
               )
               ((wcmatch (setq str (vla-get-textoverride x)) "*(VIF)*")
                (vla-put-textoverride x (vl-string-subst "" "(VIF)" str))
               )
               ((wcmatch (setq str (vla-get-textoverride x)) "*VIF*")
                (vla-put-textoverride x (vl-string-subst "" "VIF" str))
               )
               ((wcmatch (setq str (vla-get-textoverride x)) "*%%p\**")
                (vla-put-textoverride x (vl-string-subst "" "%%p*" str))
               )
               ((wcmatch (setq str (vla-get-textoverride x)) "*%%P\**")
                (vla-put-textoverride x (vl-string-subst "" "%%P*" str))
               )
         )
       )

  )
  (princ) ;exit quietly
)
Title: need help
Post by: ELOQUINTET on June 10, 2004, 10:47:09 AM
cab here's what i get

; error: Automation Error. Calling method AddItems of interface
IAcadSelectionSet failed
Title: need help
Post by: CAB on June 10, 2004, 11:02:23 AM
Not sure why you get that error.
Recopy the routine above and try on another drawing.
If it works, sent me the drawing that it did not work in.

CAB
Title: need help
Post by: Jeff_M on June 10, 2004, 12:12:50 PM
Taking from CAB's idea yesterday, here's a revised version that works rather well.

Code: [Select]

(defun c:del_vif(/ str ss)
  (vl-load-com)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-startundomark doc)
  (and (ssget "X" '((0 . "*DIM*")));get all dimension objects
       (setq ss (vla-get-activeselectionset
        (vla-get-activedocument
          (vlax-get-acad-object))));use ActiveX ss
(vlax-for x ss
 (setq str (vla-get-textoverride x))
 (mapcar '(lambda (ms)
          (if (wcmatch str (strcat "*" ms "*"))
                   (vla-put-textoverride x (vl-string-subst "" ms str))
                     ))
       '("(VIF)" "(vif)" "vif" "VIF" "v.i.f." "V.I.F." "±"))
        ;; Add any other strings to remove to the above list
)
       )
  (vla-endundomark doc)
  (princ);exit quietly
  )


Jeff
Title: need help
Post by: ELOQUINTET on June 10, 2004, 12:34:59 PM
that one works for me (no error) great job jeff
Title: need help
Post by: CAB on June 10, 2004, 12:35:50 PM
Jeff,
Good job :) , I added code to remove the entire "%%P*".
Looks like there could be many variations of special characters.

Next Dan will be asking for a routine to select the dimension with
a text override and it would then remove all matching on the database. :shock:

CAB

Code: [Select]
(defun c:del_vif(/ str ss)
  (vl-load-com)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-startundomark doc)
  (and (ssget "X" '((0 . "*DIM*")));get all dimension objects
       (setq ss (vla-get-activeselectionset
        (vla-get-activedocument
          (vlax-get-acad-object))));use ActiveX ss
   (vlax-for x ss
     (setq str (vla-get-textoverride x))
     (mapcar '(lambda (ms)
         (if (wcmatch str (strcat "*" ms "*"))
               (vla-put-textoverride x
                 (vl-string-subst ""
                   (vl-string-subst "" "\\" ms) str))
                         ))
           '("(VIF)" "(vif)" "vif" "VIF" "v.i.f." "V.I.F." "%%p\*" "%%P\*"))
            ;; Add any other strings to remove to the above list
   )
       )
  (vla-endundomark doc)
  (princ);exit quietly
)
Title: need help
Post by: ELOQUINTET on June 10, 2004, 12:44:29 PM
o gimme gimme gimme  :P
Title: need help
Post by: Mark on June 10, 2004, 02:01:42 PM
- CAB, Jeff

excellent stuff you guys.

Dan, beer's on you ............... we'll be over around 7.
Title: need help
Post by: ELOQUINTET on June 10, 2004, 02:11:44 PM
>>>slides a cold one down the bar<<<

why wait til 7 here ya go

 8)
Title: need help
Post by: Slim© on June 10, 2004, 02:13:12 PM
It's 5 O'clock somewhere.
Title: need help
Post by: CAB on June 10, 2004, 04:58:24 PM
Here is version one. The entire dim override is deleted.
Thinking about adding the option to edit the text to match of the Dim override.
So you could edit "11'-1" %%p*" to read "%%p*" and only the %%p* would be deleted.
And perhaps an option to replace the %%p* with user entered text.
Not sure which options if any would be useful?


Code: [Select]
;;;  DimTextDel.lsp by Charles Alan Butler
;;;             Copyright 2004            
;;;  by Precision Drafting & Design All Rights Reserved.
;;;  Contact at ab2draft@TampaBay.rr.com
;;;
;;;   Version 1.0 Beta  June 10,2004
;;;
;;; DESCRIPTION
;;; User picks dimension with text override and routine deletes
;;; all override text overrides in dims with matching override
;;;
;;;
;;;  Limitations
;;;  Deletes the entire override text
;;;
;;;
;;; Command Line Usage
;;; Command: dimtextdel
;;;         Select Dimension with Text to delete.
;;;
;;;
;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
;;;   WARRANTY.  ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
;;;   PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
;;;                                                                    ;
;;;  You are hereby granted permission to use, copy and modify this    ;
;;;  software without charge, provided you do so exclusively for       ;
;;;  your own use or for use by others in your organization in the     ;
;;;  performance of their normal duties, and provided further that     ;
;;;  the above copyright notice appears in all copies and both that    ;
;;;  copyright notice and the limited warranty and restricted rights   ;
;;;  notice appear in all supporting documentation.                    ;
(defun c:dimtextdel (/ str ss ovrtxt)
  (vl-load-com)
  (if (setq dm (entsel "\nSelect Dimension with Text to delete."))
    (progn
      (setq doc (vla-get-activedocument (vlax-get-acad-object)))
      (setq dm (vlax-ename->vla-object (car dm)))
      (if (wcmatch (vla-get-objectname dm) "*Dimension")
        (if (/= (setq ovrtxt (vla-get-textoverride dm)) "")
          (progn
            (vla-startundomark doc)
            (and
              (ssget "X" '((0 . "*DIM*"))) ;get all dimension objects
              (setq ss (vla-get-activeselectionset
                         (vla-get-activedocument
                           (vlax-get-acad-object)
                         )
                       )
              ) ;use ActiveX ss
              (vlax-for x ss
                (if (= (setq str (vla-get-textoverride x)) ovrtxt)
                       (vla-put-textoverride x "")
                )
              )
            ); and
            (vla-endundomark doc)
          ); progn
          (alert "\n\tNo Text Override in Dimension\t")
        )
        (alert "\n\Not a Dimension\t")
      )
    )
  )
  (princ) ;exit quietly
)
(prompt "\nDimension Text Delete loaded, enter dimtextdel to run.")
(princ)
Title: need help
Post by: CAB on June 10, 2004, 06:01:58 PM
Ok, here is version 1.1
You edit the text override, removing the text to keep.
Note that the remaining text after editing must be a match to existing.
Like "11'1\" %%p*" can be edited to "%%p*" and "%%p*" will be removed.
But "SEE TABLE A1" edited to "SEE A1" will not work because there is no
match.
The work around is this:
you may do this "SEE TABLE A1" --> "SEE "
and then "SEE TABLE A1" --> " A1"
leaving TABLE

PS one problem with ddedit. If you hit Escape it returns you to the routine
and the complete text override is deleted. Is there a way to tell if it was
exited via escape vs enter?

Code: [Select]
;;;  DimTextDel.lsp by Charles Alan Butler
;;;             Copyright 2004            
;;;  by Precision Drafting & Design All Rights Reserved.
;;;  Contact at ab2draft@TampaBay.rr.com
;;;
;;;   Version 1.0 Beta  June 10,2004
;;;   Version 1.1 Beta  June 10,2004
;;;     Added edit of text override to remove
;;;
;;; DESCRIPTION
;;; User picks dimension with text override and routine deletes
;;; all overide text overrides in dims with matching override
;;;
;;;
;;;  Limitations
;;;  Text edit is limited, remaining text must be unbroken
;;;    "11'1\" %%p*" --> "%%p*"  is OK
;;;    "SEE TABLE A1" --> "SEE A1"  will fail to match
;;;       you may do this "SEE TABLE A1" --> "SEE "
;;;
;;;
;;; Command Line Usage
;;; Command: dimtextdel
;;;         Select Dimension with Text to remove.
;;;
;;;
;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
;;;   WARRANTY.  ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
;;;   PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
;;;                                                                    ;
;;;  You are hereby granted permission to use, copy and modify this    ;
;;;  software without charge, provided you do so exclusively for       ;
;;;  your own use or for use by others in your organization in the     ;
;;;  performance of their normal duties, and provided further that     ;
;;;  the above copyright notice appears in all copies and both that    ;
;;;  copyright notice and the limited warranty and restricted rights   ;
;;;  notice appear in all supporting documentation.                    ;
(defun c:dimtextdel (/ str ss dm ovrtxt repltxt txt)
  ;;  ===============  ERROR ROUTINE  =================
  (defun *error* (msg)
    (if
      (not
        (member
          msg
          '("console break" "Function cancelled" "quit / exit abort" "")
        )
      )
       (princ (strcat "\nError: " msg))
    ) ; if
    (setvar "CMDECHO" usercmd)
    (if txt
      (progn
        (entdel txt)
        (setq txt nil)
      )
    )
    (princ)
  ) ;
 ;end error function
;;;  =================================================================
;;;                       Main Routine
;;;  =================================================================
  (setq usercmd (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (vl-load-com)
  (if (setq dm (entsel "\nSelect Dimension with Text to remove."))
    (progn
      (setq doc (vla-get-activedocument (vlax-get-acad-object)))
      (setq dm (vlax-ename->vla-object (car dm)))
      (if (wcmatch (vla-get-objectname dm) "*Dimension")
        (if (/= (setq ovrtxt (vla-get-textoverride dm)) "")
          (progn
            (if (entmake (list '(0 . "TEXT")
                               (cons 10 '(0 0))
                               (cons 40 (getvar "TEXTSIZE"))
                               (cons 7 (getvar "TEXTSTYLE"))
                               (cons 1 ovrtxt) ; Text String
                         )
                )
              (setq txt (entlast))
              (quit)
            ) ; endif
            (prompt
              "\nDelete the text you want to keep or press Enter to delete all."
            )
            (command "._ddedit" txt "")
            (setq repltxt (cdr (assoc 1 (entget txt))))
            (entdel txt)
            (setq txt nil)
            (vla-startundomark doc)
            (and
              (ssget "X" '((0 . "*DIM*"))) ;get all dimension objects
              (setq ss (vla-get-activeselectionset
                         (vla-get-activedocument
                           (vlax-get-acad-object)
                         )
                       )
              ) ;use ActiveX ss
              (vlax-for x ss
                (if (= (setq str (vla-get-textoverride x)) ovrtxt)
                  (vla-put-textoverride
                    x
                    (vl-string-subst "" repltxt ovrtxt)
                  )
                )
              )
            ) ; and
            (vla-endundomark doc)
          ) ; progn
          (alert "\n\tNo Text Override in Dimension\t")
        )
        (alert "\n\tNot a Dimension\t")
      )
    )
  )
  (princ) ;exit quietly
)
(prompt
  "\nDimension Text Delete loaded, enter dimtextdel to run."
)
(princ)
Title: need help
Post by: Keith™ on June 15, 2004, 11:40:50 PM
Dangit ... this looks almost like an Autodork forum ... shoot before we can get comfortable with the software someone goes and presents an UPGRADE... what is the world coming to....
Title: need help
Post by: CAB on June 16, 2004, 07:49:36 AM
LOL - you are quite right. :)

Where have you been?

I started a dcl version to overcome the ddedit problem but quit do to lack
of interest both here and mine. Seems work is overrunning me too.
Title: need help
Post by: Keith™ on June 16, 2004, 08:08:50 AM
Well, I have been busy on other ventures like WORK ... been under the gun for some time and it dies not look like it will get any better real soon
Title: need help
Post by: ELOQUINTET on June 16, 2004, 09:13:45 AM
someone asked me a question that i didn't have the answer to so i'll ask you guys. i showed him how to copy and paste viewports from one layout to another then turn mv on. when he tries to copy another he gets the original. how can he do another?