Author Topic: Flag if dimension is not associative  (Read 10234 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Flag if dimension is not associative
« Reply #15 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
« Last Edit: January 24, 2008, 04:28:26 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Flag if dimension is not associative
« Reply #16 on: January 24, 2008, 03:08:18 PM »
 :oops:
Excuse me.
I answered other question...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Flag if dimension is not associative
« Reply #17 on: January 24, 2008, 03:10:03 PM »
Not a problem, Happens to me a lot & it's my only language. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Flag if dimension is not associative
« Reply #18 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-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Flag if dimension is not associative
« Reply #19 on: January 24, 2008, 03:40:44 PM »
>CAB
You tried to simplify a code?  :-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Flag if dimension is not associative
« Reply #20 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-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
Re: Flag if dimension is not associative
« Reply #21 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?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Flag if dimension is not associative
« Reply #22 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.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
Re: Flag if dimension is not associative
« Reply #23 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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Flag if dimension is not associative
« Reply #24 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.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
Re: Flag if dimension is not associative
« Reply #25 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

ELOQUINTET

  • Guest
Re: Flag if dimension is not associative
« Reply #26 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.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Flag if dimension is not associative
« Reply #27 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)
« Last Edit: January 24, 2008, 05:17:30 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ELOQUINTET

  • Guest
Re: Flag if dimension is not associative
« Reply #28 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
)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Flag if dimension is not associative
« Reply #29 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.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.