TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: ELOQUINTET on January 23, 2008, 11:08:28 AM

Title: Flag if dimension is not associative
Post by: ELOQUINTET on January 23, 2008, 11:08:28 AM
Hey guys,

Do any of you have a routine which will flag any dims which are not associative? The new place is dimensioning in paper space and it's driving me bonkers
Title: Re: Flag if dimension is not associative
Post by: Josh Nieman on January 23, 2008, 11:14:48 AM
"Associative" is a read-only (unless it's associative, you can turn that off, but it's a one-way street from the properties menu) and is a listed property of a dimension object, so you could probably just find out what dxf value is tied to that, and check for the corresponding number.
Title: Re: Flag if dimension is not associative
Post by: CAB on January 23, 2008, 11:20:34 AM
This may help:
http://www.theswamp.org/index.php?topic=7788.0
Title: Re: Flag if dimension is not associative
Post by: ELOQUINTET on January 23, 2008, 02:37:30 PM
another thing that might be useful for me at this point would be an alert when any of my dimensions become non associative instead of discovering it after i've done a bunch of work and have to wind up redoing one or the other. i haven't been able to find a completed routine on the net which is somewhat surprising to me.
Title: Re: Flag if dimension is not associative
Post by: mkweaver on January 24, 2008, 09:06:43 AM
This won't flag your dimensions automatically, but running the routine and selecting all at the prompt will flag all dimensions with overrides:

Code: [Select]
(defun c:FlagForcedDims( / ss1 ssl indx obj to)
  (cond
    ((null (setq ss1 (ssget '((0 . "DIMENSION")))))
     nil
     )
    ((= 0 (setq ssl (sslength ss1)))
     (princ "\nNothing selected.")
     )
    (T
     (setq indx -1)
     (while (> ssl (setq indx (1+ indx)))
       (setq
obj (vlax-ename->vla-object (ssname ss1 indx))
to (vla-get-textoverride obj)
)
       (if (= "" to)
nil
(progn
   (vla-put-textcolor obj 1)
   (vla-put-lineweight obj 80)
   (vla-put-textoverride obj (strcat to " measures " (rtos (vla-get-measurement obj))))
)
)
       )
     )
    )
  (princ)
  )

The result looks like this:
Title: Re: Flag if dimension is not associative
Post by: daron on January 24, 2008, 09:06:55 AM
It could be because most people avoid assoc. dims. because of the one-way street and the possibility of easy disassociation.
Title: Re: Flag if dimension is not associative
Post by: ELOQUINTET on January 24, 2008, 09:42:34 AM
i appreciate the try mv but i'm not sure this is what i'm after. they are dimensioning object that are in paperspace in paperspace here. i am building their library and am not accustomed to this method and sometimes move things and leave behind dimensions or by habit stretch via grips or add one note then copy it. all of these practices and probably more to come are disassociating the dimensions from the objects and I need a quick way of checking that I have not made a boo boo before determining that a drawing is complete. i am really in need of this in a bad way so if someone could be so kind as to help me out it would save me from pulling alot of hair out.
Title: Re: Flag if dimension is not associative
Post by: Josh Nieman on January 24, 2008, 09:55:08 AM
What if you used the same code as was written, but instead of changing the text... maybe it'd change the dimlines and text colors to something that would stand out from the rest of your drawing like a lime green or magenta or something bright?

That was you could run it... all non-conforming dimensions would be given a NEON GLOW so to speak... and you could quickly see which were 'off' and fix them... then select all dims and return to normal settings.
Title: Re: Flag if dimension is not associative
Post by: ELOQUINTET on January 24, 2008, 11:18:36 AM
that would work much better. I just need a visual cue to tell me if any dimensions have lost their association. Thanks
Title: Re: Flag if dimension is not associative
Post by: Josh Nieman on January 24, 2008, 12:07:09 PM
Where his says:

Code: [Select]

   (vla-put-textcolor obj 4)
   (vla-put-lineweight obj 4)
   (vla-put-textoverride obj 4)

replace those lines with:

Code: [Select]
            (setq JN (subst (62 . 4) (assoc 62 JN) JN))


Did I do this right?  I'm trying to change the 'color' value to CYAN (4) :|  I'm totally confused now, though.
Title: Re: Flag if dimension is not associative
Post by: ElpanovEvgeniy on January 24, 2008, 12:13:28 PM
This won't flag your dimensions automatically, but running the routine and selecting all at the prompt will flag all dimensions with overrides:

Code: [Select]
(defun c:FlagForcedDims( / ss1 ssl indx obj to)
  (cond
    ((null (setq ss1 (ssget '((0 . "DIMENSION")))))
     nil
     )
    ((= 0 (setq ssl (sslength ss1)))
     (princ "\nNothing selected.")
     )
    (T
     (setq indx -1)
     (while (> ssl (setq indx (1+ indx)))
       (setq
obj (vlax-ename->vla-object (ssname ss1 indx))
to (vla-get-textoverride obj)
)
       (if (= "" to)
nil
(progn
   (vla-put-textcolor obj 1)
   (vla-put-lineweight obj 80)
   (vla-put-textoverride obj (strcat to " measures " (rtos (vla-get-measurement obj))))
)
)
       )
     )
    )
  (princ)
  )

The result looks like this:


If the text will be " <> " your program will give a mistake
Title: Re: Flag if dimension is not associative
Post by: ElpanovEvgeniy on January 24, 2008, 12:21:46 PM
My old program...

Code: [Select]
(defun d-orig (/ EN SS)
 ;;(d-orig)
 (if (setq ss (ssget "_X" '((0 . "DIMENSION") (-4 . "<AND") (1 . "*?*") (1 . "~*<>*") (-4 . "AND>"))))
  (foreach x (mapcar (function cadr) (ssnamex ss))
   (setq en (entget x))
   (entmod (subst (cons 1 (strcat (cdr (assoc 1 en)) "{\\C1; (Original: <>) }")) (assoc 1 en) en))
   (entupd x)
  ) ;_  foreach
 ) ;_  if
)
Title: Re: Flag if dimension is not associative
Post by: ELOQUINTET on January 24, 2008, 12:34:38 PM
ummm Elpanov you are confusing me. The routine I am looking for will tell me if a dimension is non associative. I do not need to know if the dimension has been overridden. Well I do but I already have a routine that I'm happy with for that. That is what yours is doing right?
Title: Re: Flag if dimension is not associative
Post by: ElpanovEvgeniy on January 24, 2008, 12:38:27 PM
ummm Elpanov you are confusing me. The routine I am looking for will tell me if a dimension is non associative. I do not need to know if the dimension has been overridden. Well I do but I already have a routine that I'm happy with for that. That is what yours is doing right?
As an example, I have replaced the text of the size on " <> mm " it does not mean, that the size will be not exact!
Title: Re: Flag if dimension is not associative
Post by: ElpanovEvgeniy on January 24, 2008, 12:43:59 PM
Similar theme (http://www.theswamp.org/index.php?topic=6874.msg129536#msg129536)
Title: Re: Flag if dimension is not associative
Post by: CAB on January 24, 2008, 03:00:17 PM
Dan, give this a try.
Code: [Select]
;;  FlagNonAssocDims, by CAB at TheSwamp.org  01.24.2008
;;  Places a block over Non Associated Dim's
(defun c:FNAD( / ss lst itm pt blk sc doc Space
                        GetDimAssocFlag)
  ;;  by MP http://www.theswamp.org/index.php?topic=7788.msg99023#msg99023
  ;;  Will return a bitsum value reflecting associativity (+ 1 2 4 8) or nil.
  (defun GetDimAssocFlag ( dimobj / result )
    (if (eq :vlax-true (vla-get-hasextensiondictionary dimobj))
        (vl-catch-all-apply
           '(lambda ( )
                (setq result
                    (cdr
                        (assoc 90
                            (entget
                                (vlax-vla-object->ename
                                    (vla-getobject
                                        (vla-getextensiondictionary dimobj)
                                        "ACAD_DIMASSOC"
                                    )
                                )   
                            )
                        )
                    )
                )   
            )
        )
    )
    result
  )

 
  (if (not(tblsearch "BLOCK" "NotAllowed"))
    (progn
      (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbBlockReference")
                 (2 . "NotAllowed") (10 0.0 0.0 0.0) (70 . 0)))
      (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbPolyline")
                 (90 . 2) (70 . 0) (43 . 0.1) (38 . 0.0) (39 . 0.0)(10 0.707107358883519 0.707106203489104)
                 (40 . 0.1) (41 . 0.1) (42 . 0.0) (10 -0.707107358883519 -0.707106203489104)
           (40 . 0.1) (41 . 0.1) (42 . 0.0)))
      (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbPolyline") (90 . 2)
                 (70 . 1) (43 . 0.1) (38 . 0.0) (39 . 0.0) (10 0.707107358883519 0.707106203489104) (40 . 0.1)
                 (41 . 0.1) (42 . -1.0) (10 -0.707107358883519 -0.707106203489104) (40 . 0.1) (41 . 0.1)
                 (42 . -1.0)))
      (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0")))
    )
  )

  (prompt "\nSelect Dim's to test associativity.")
  (if(setq ss (ssget '((0 . "DIMENSION"))))
    (progn
     (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
     (setq Space (if (= 1 (getvar "CVPORT")) (vla-get-PaperSpace Doc) (vla-get-ModelSpace Doc)))
     (setq lst (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))
     (foreach itm lst
       (if (not(GetDimAssocFlag itm))
(progn
          (setq pt (vla-get-TextPosition itm)
                sc (vla-get-ScaleFactor itm))
          (setq blk (vla-insertblock Space
  pt ; insert point
  "NotAllowed" ; block name
  sc sc sc  ; scale x y z
  0.0  ; radians
)
          )
          (vla-put-layer blk "0") ; Layer
          (vlax-release-object blk)
)
       )
     )
    )
  )
  (princ)
)
(prompt "\nFlagNonAssocDims loaded, Enter FNAD to run.")
(princ)

Updated Code
Title: Re: Flag if dimension is not associative
Post by: ElpanovEvgeniy on January 24, 2008, 03:08:18 PM
 :oops:
Excuse me.
I answered other question...
Title: Re: Flag if dimension is not associative
Post by: CAB on January 24, 2008, 03:10:03 PM
Not a problem, Happens to me a lot & it's my only language. :-)
Title: Re: Flag if dimension is not associative
Post by: CAB on January 24, 2008, 03:23:22 PM
Off topic but I found this interesting:
My old program...

Code: [Select]
(defun d-orig (/ EN SS)
 ;;(d-orig)
 (if (setq ss (ssget "_X" '((0 . "DIMENSION") (-4 . "<AND") (1 . "*?*") (1 . "~*<>*") (-4 . "AND>"))))
  (foreach x (mapcar (function cadr) (ssnamex ss))
   (setq en (entget x))
   (entmod (subst (cons 1 (strcat (cdr (assoc 1 en)) "{\\C1; (Original: <>) }")) (assoc 1 en) en))
   (entupd x)
  ) ;_  foreach
 ) ;_  if
)

This one is tricky
Code: [Select]
(setq ss (ssget "_X" '((0 . "DIMENSION") (-4 . "<AND") (1 . "*?*") (1 . "~*<>*") (-4 . "AND>"))))This (1 . "*?*") says the string must have one character i.e. not ""
This (1 . "~*<>*") says must not have "<>" in the string
If you use (1 . "*?*,~*<>*") it says (not "" OR not "<>") but you want to say AND
therfore you must use (-4 . "<AND") (1 . "*?*") (1 . "~*<>*") (-4 . "AND>")
which says (not "" AND not "<>")

Neat stuff Evgeniy  8-)
Title: Re: Flag if dimension is not associative
Post by: ElpanovEvgeniy on January 24, 2008, 03:40:44 PM
>CAB
You tried to simplify a code?  :-)
Title: Re: Flag if dimension is not associative
Post by: CAB on January 24, 2008, 03:54:09 PM
I tried before I understood what it was doing.
That led me to understand the meaning. 8-)
Title: Re: Flag if dimension is not associative
Post by: ELOQUINTET on January 24, 2008, 04:19:14 PM
cab i setup a drawing with one assoc and another non assoc and ran the routine but don't see the "not allowed" block. I see that it exists in the drawing but where is it placed, what is the size based on?
Title: Re: Flag if dimension is not associative
Post by: CAB on January 24, 2008, 04:29:49 PM
Boy, batting 1000 today. :x

I changed the code, so copy it again & try it.

Sorry Dan, I had it working in model space & not paper space.

PS the scale of the block is same as DIMSCALE but I may need to change that too for paper space.
Title: Re: Flag if dimension is not associative
Post by: ELOQUINTET on January 24, 2008, 04:38:41 PM
gotcha i figured it was something along those lines. look at my other posting, need help there again. thanks for your help man you are a lifesaver i swear.
Title: Re: Flag if dimension is not associative
Post by: CAB on January 24, 2008, 04:44:04 PM
Oh, this routine scales the block to that Scale Factor for the DIM it is flagging.
Maybe that will work.
Title: Re: Flag if dimension is not associative
Post by: ELOQUINTET on January 24, 2008, 04:44:19 PM
cab is there a way to make that about 1/8 the size it is now. it's gigantic and if i have multiple small dimensions side by side it's hard to tell which is the problem. Other than that it is just what the doctor ordered. You da man
Title: Re: Flag if dimension is not associative
Post by: ELOQUINTET on January 24, 2008, 04:46:50 PM
by the way is there a way to skip the select objects part and just select all the dimensions automatically. It's not a big deal but it would insure that none were missed.
Title: Re: Flag if dimension is not associative
Post by: CAB on January 24, 2008, 04:58:44 PM
Try this, change the blkScale var as needed. This version is automatic & processes current space.
Code: [Select]
;;  FlagNonAssocDims, by CAB at TheSwamp.org  01.24.2008
;;  Places a block over Non Associated Dim's
(defun c:FNAD( / ss lst itm pt blk sc doc Space blksize
                        GetDimAssocFlag)

  (setq blksize 1.0)  ; scale of the block size, change to suit

 
  ;;  by MP http://www.theswamp.org/index.php?topic=7788.msg99023#msg99023
  ;;  Will return a bitsum value reflecting associativity (+ 1 2 4 8) or nil.
  (defun GetDimAssocFlag ( dimobj / result )
    (if (eq :vlax-true (vla-get-hasextensiondictionary dimobj))
        (vl-catch-all-apply
           '(lambda ( )
                (setq result
                    (cdr
                        (assoc 90
                            (entget
                                (vlax-vla-object->ename
                                    (vla-getobject
                                        (vla-getextensiondictionary dimobj)
                                        "ACAD_DIMASSOC"
                                    )
                                )   
                            )
                        )
                    )
                )   
            )
        )
    )
    result
  )

 
  (if (not(tblsearch "BLOCK" "NotAllowed"))
    (progn
      (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbBlockReference")
                 (2 . "NotAllowed") (10 0.0 0.0 0.0) (70 . 0)))
      (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbPolyline")
                 (90 . 2) (70 . 0) (43 . 0.1) (38 . 0.0) (39 . 0.0)(10 0.707107358883519 0.707106203489104)
                 (40 . 0.1) (41 . 0.1) (42 . 0.0) (10 -0.707107358883519 -0.707106203489104)
           (40 . 0.1) (41 . 0.1) (42 . 0.0)))
      (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbPolyline") (90 . 2)
                 (70 . 1) (43 . 0.1) (38 . 0.0) (39 . 0.0) (10 0.707107358883519 0.707106203489104) (40 . 0.1)
                 (41 . 0.1) (42 . -1.0) (10 -0.707107358883519 -0.707106203489104) (40 . 0.1) (41 . 0.1)
                 (42 . -1.0)))
      (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0")))
    )
  )

  ;;(prompt "\nSelect Dim's to test associativity.")
  (if(setq ss (ssget "X" (list '(0 . "DIMENSION")(cons 410 (getvar "ctab")))))
    (progn
     (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
     (setq Space (if (= 1 (getvar "CVPORT")) (vla-get-PaperSpace Doc) (vla-get-ModelSpace Doc)))
     (setq lst (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))
     (foreach itm lst
       (if (not(GetDimAssocFlag itm))
(progn
          (setq pt (vla-get-TextPosition itm)
                sc blksize  ; (vla-get-ScaleFactor itm)
          )
          (setq blk (vla-insertblock Space
  pt ; insert point
  "NotAllowed" ; block name
  sc sc sc  ; scale x y z
  0.0  ; radians
)
          )
          (vla-put-layer blk "0") ; Layer
          (vlax-release-object blk)
)
       )
     )
    )
  )
  (princ)
)
(prompt "\nFlagNonAssocDims loaded, Enter FNAD to run.")
(princ)
Title: Re: Flag if dimension is not associative
Post by: ELOQUINTET on January 24, 2008, 05:15:46 PM
cab i believe i know which section you are refering to but don't know what format to enter my scale. am i right about the section at least?

Code: [Select]
          (setq blk (vla-insertblock Space
  pt ; insert point
  "NotAllowed" ; block name
  sc sc sc  ; scale x y z
  0.0  ; radians
)
Title: Re: Flag if dimension is not associative
Post by: CAB on January 24, 2008, 05:16:33 PM
Nope, put it here:
 (setq blksize 1.0)  ; scale of the block size, change to suit

PS recopy the last lisp, I commented out a paren that was needed.
Title: Re: Flag if dimension is not associative
Post by: ELOQUINTET on January 24, 2008, 05:25:37 PM
ok got it, one last small request if i may. is there a way that the block can have a unique color that will stand out. yellow would be the best i think. other than that it is just what i was looking for and i am extremely grateful.
Title: Re: Flag if dimension is not associative
Post by: CAB on January 24, 2008, 05:30:39 PM
(vla-put-color blk acYellow)
 8-)
Title: Re: Flag if dimension is not associative
Post by: GDF on January 24, 2008, 06:14:40 PM
ok got it, one last small request if i may. is there a way that the block can have a unique color that will stand out. yellow would be the best i think. other than that it is just what i was looking for and i am extremely grateful.

Alan

Why not add this to your great routine:

;;;               DimPrec.lsp                 
;;;    By Charles Alan Butler  04/27/2003
;;; This routine will flag all dims that have dimension text
;;; over ridden or have a precision greater less than 1/32 .
;;; One or more of the following symbols are placed over the dimension
;;;
;;; Symbols
;;;  CHECK    = Dimensions that have a precision >= 1/32
;;;  S        = Dimensions that are STYLE dependent for precision
;;;  Circle/  = Dimensions with precision less than 1/32 (0.00000)
;;;  SquareX  = Dimensions that have Text Overrides
;;;  Diamond+ = Dimensions that are rounded off & precision is ok
;;;
;;; The symbols used are placed on Layer "DefPoints"
;;; and sized according to DIMTXT size variable,
;;; or the Text Style of the DIM if it's size > 0
;;;
;;;  Limitations : 
;;;       not designed to work in paper space.
;;;       USCS World plan view only
;;;
;;;  Revision 04/12/04
;;;   Correction for ACAD2000, blocks are created on layer 0 now
;;;   Dims selected are visible in space you are working
;;;     not All dims & frozen as before
;;;   Streamlined code
;;;
;;;  Revision 12/17/05
;;;   Added the Rounded Off flagging of dimensions that are within
;;;   the precision of the style
;;;
;;; Revision 12/20/05
;;;   Revised routine to be call by another lisp
;;;   Arguments:
;;;     mode  one of two modes "Display" or "Remove"
;;;   Returns results in a list of strings

Gary


Title: Re: Flag if dimension is not associative
Post by: CAB on January 24, 2008, 07:32:21 PM
Good memory Gary. :-)
Title: Re: Flag if dimension is not associative
Post by: ELOQUINTET on January 25, 2008, 09:48:26 AM
cab i tried adding it here in the code but the block still comes in white. did i do it wrong?

Code: [Select]
          (vla-put-layer blk "0"); Layer
          (vla-put-color blk acYellow); Color
          (vlax-release-object blk)
Title: Re: Flag if dimension is not associative
Post by: CAB on January 25, 2008, 10:52:36 AM
Scratch that & replace this section:
Code: [Select]
  (if (not(tblsearch "BLOCK" "NotAllowed"))
    (progn
      (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (67 . 0) (8 . "0") (100 . "AcDbBlockReference")
                 (2 . "NotAllowed") (10 0.0 0.0 0.0) (70 . 0)))
      (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (67 . 0) (8 . "0") (62 . 2) (100 . "AcDbPolyline")
                 (90 . 2) (70 . 0) (43 . 0.1) (38 . 0.0) (39 . 0.0)(10 0.707107358883519 0.707106203489104)
                 (40 . 0.1) (41 . 0.1) (42 . 0.0) (10 -0.707107358883519 -0.707106203489104)
           (40 . 0.1) (41 . 0.1) (42 . 0.0)))
      (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (67 . 0) (8 . "0") (62 . 2) (100 . "AcDbPolyline") (90 . 2)
                 (70 . 1) (43 . 0.1) (38 . 0.0) (39 . 0.0) (10 0.707107358883519 0.707106203489104) (40 . 0.1)
                 (41 . 0.1) (42 . -1.0) (10 -0.707107358883519 -0.707106203489104) (40 . 0.1) (41 . 0.1)
                 (42 . -1.0)))
      (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0")))
    )
  )

Note: you will need to purge the block before this code will take effect.
Title: Re: Flag if dimension is not associative
Post by: ELOQUINTET on January 25, 2008, 11:20:49 AM
cab just to let you know both this and the reactor are now working great. the only thing i noticed with the block is that the line that goes through the circle is still white but that's not a big deal. I amy want to change the color of this symbol as i work with it so i'm assuming i need to modify something in the snippet you just gave me. which part is the color? thanks a ton my friend you are the best.
Title: Re: Flag if dimension is not associative
Post by: CAB on January 25, 2008, 11:37:18 AM
That's good to hear. I revised the code above so replace it again.