Author Topic: associative dimentions, can i turn of associative in vlisp?  (Read 4231 times)

0 Members and 1 Guest are viewing this topic.

Amsterdammed

  • Guest
hello there,

it seems that the vertical we are using has a problem with associative dimensions, sometimes they all go bananas and run all over the place after certain commands. so, can i turn the asso of with a vlisp in existing dimensions?

Thanks!

BlackBox

  • King Gator
  • Posts: 3770
Re: associative dimentions, can i turn of associative in vlisp?
« Reply #1 on: July 05, 2012, 10:41:02 AM »
Consider the DIMASSOC System Variable for new Dimensions... Not really sure how to do this for existing Dimensions.

"How we think determines what we do, and what we do determines what we get."

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: associative dimentions, can i turn of associative in vlisp?
« Reply #2 on: July 05, 2012, 10:56:11 AM »
Not really sure how to do this for existing Dimensions.
Move the dimensions an arbitrary distance away, then move them back again.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

zoltan

  • Guest
Re: associative dimentions, can i turn of associative in vlisp?
« Reply #3 on: July 05, 2012, 12:01:15 PM »
Remove the ACAD_DIMASSOC record from the dimension's Extension Dictionary.

Code - Auto/Visual Lisp: [Select]
  1. (Defun C:RemoveAssoc()
  2.  
  3.  
  4.   (SetQ eDim (Car (EntSel)) )
  5.  
  6.   (SetQ oDictionary (VLA-GetExtensionDictionary (VLAX-Ename->VLA-Object eDim)) )
  7.  
  8.   (SetQ entAssocDict (DictSearch (VLAX-VLA-Object->Ename oDictionary) "ACAD_DIMASSOC") )
  9.  
  10.   (EntDel (Cdr (Assoc -1 entAssocDict)))
  11.  
  12.   (DictRemove (VLAX-VLA-Object->Ename oDictionary) "ACAD_DIMASSOC" )
  13.  
  14. )
  15.  


(WARNING:  I have not written Lisp in a few years!  That may not be the right way to do it!)


BlackBox

  • King Gator
  • Posts: 3770
Re: associative dimentions, can i turn of associative in vlisp?
« Reply #4 on: July 05, 2012, 12:07:41 PM »
Remove the ACAD_DIMASSOC record from the dimension's Extension Dictionary.

Code - Auto/Visual Lisp: [Select]
  1. (Defun C:RemoveAssoc()
  2.  
  3.  
  4.   (SetQ eDim (Car (EntSel)) )
  5.  
  6.   (SetQ oDictionary (VLA-GetExtensionDictionary (VLAX-Ename->VLA-Object eDim)) )
  7.  
  8.   (SetQ entAssocDict (DictSearch (VLAX-VLA-Object->Ename oDictionary) "ACAD_DIMASSOC") )
  9.  
  10.   (EntDel (Cdr (Assoc -1 entAssocDict)))
  11.  
  12.   (DictRemove (VLAX-VLA-Object->Ename oDictionary) "ACAD_DIMASSOC" )
  13.  
  14. )
  15.  


(WARNING:  I have not written Lisp in a few years!  That may not be the right way to do it!)

I love the disclaimer, Zoltan... Just beware (= eDim nil).  ;-)

"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3770
Re: associative dimentions, can i turn of associative in vlisp?
« Reply #5 on: July 05, 2012, 12:18:41 PM »
Also, take from this what you will....

You really should test for the selection(s) being valid dimension entities, on unlocked layers, and include vl-catch-all-apply in the case where Dimensions that have no association are selected.

Pseudo code:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:RDA () (c:RemDimAssoc))
  2. (defun c:RemDimAssoc  (/ _RemDimAssoc ss i eName)
  3.   (princ "\rREMDIMASSOC ")
  4.  
  5.   (defun _RemDimAssoc  (eName / oDictionary)
  6.     (vl-catch-all-apply
  7.       'entdel
  8.       (list (cdr (assoc -1
  9.                         (dictsearch
  10.                           (vlax-vla-object->ename
  11.                             (setq oDictionary
  12.                                    (vla-getextensiondictionary
  13.                                      (vlax-ename->vla-object eName))))
  14.                           "ACAD_DIMASSOC")))))
  15.     (dictremove (vlax-vla-object->ename oDictionary) "ACAD_DIMASSOC"))
  16.  
  17.   (if (setq ss (ssget "_:L" '((0 . "DIMENSION"))))
  18.     (progn
  19.       (setq i -1)
  20.       (while (setq eName (ssname ss (setq i (1+ i))))
  21.         (_RemDimAssoc eName)
  22.         )
  23.       )
  24.     (prompt "\n** Nothing selected ** ")
  25.     )
  26.   (princ)
  27.   )
  28.  

** Edit - I forgot to localize 'eName'
« Last Edit: July 05, 2012, 12:22:16 PM by RenderMan »
"How we think determines what we do, and what we do determines what we get."

zoltan

  • Guest
Re: associative dimentions, can i turn of associative in vlisp?
« Reply #6 on: July 05, 2012, 12:48:33 PM »
Thank you for the thorough error-handling, RenderMan.  I just threw that together quickly for testing purposes, I never intended anyone to use it in production.

BlackBox

  • King Gator
  • Posts: 3770
Re: associative dimentions, can i turn of associative in vlisp?
« Reply #7 on: July 05, 2012, 12:51:06 PM »
Thank you for the thorough error-handling, RenderMan.  I just threw that together quickly for testing purposes, I never intended anyone to use it in production.

Happy to help, Zoltan; I wasn't trying to harp on you. :-D LoL
"How we think determines what we do, and what we do determines what we get."

Amsterdammed

  • Guest
Re: associative dimentions, can i turn of associative in vlisp?
« Reply #8 on: July 05, 2012, 01:54:09 PM »
Thanks!

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: associative dimentions, can i turn of associative in vlisp?
« Reply #9 on: July 05, 2012, 02:06:18 PM »
I think:

Code - Auto/Visual Lisp: [Select]
  1. ;; Remove Dimension Associativity  -  Lee Mac 2012
  2. (defun c:rda ( / d e i s )
  3.     (if (setq s (ssget "_:L" '((0 . "*DIMENSION") (102 . "{ACAD_XDICTIONARY") (102 . "{ACAD_REACTORS"))))
  4.         (repeat (setq i (sslength s))
  5.             (setq e (entget (ssname s (setq i (1- i)))))
  6.             (dictremove (setq d (cdr (assoc 360 e))) "ACAD_DIMASSOC")
  7.             (if (null (dictnext d t))
  8.                 (vla-delete (vlax-ename->vla-object d))
  9.             )
  10.             (vla-delete (vlax-ename->vla-object (cdr (assoc 330 e))))
  11.         )
  12.     )
  13.     (princ)
  14. )

BlackBox

  • King Gator
  • Posts: 3770
Re: associative dimentions, can i turn of associative in vlisp?
« Reply #10 on: July 05, 2012, 02:09:41 PM »
Succinct as always, Lee.

Cheers, mate! :beer:
"How we think determines what we do, and what we do determines what we get."

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: associative dimentions, can i turn of associative in vlisp?
« Reply #11 on: July 05, 2012, 02:32:55 PM »
Succinct as always, Lee.

Cheers, mate! :beer:

Thanks Renderman  :-)

Be careful with yours, as although it deletes and removes the DIMASSOC Dictionary (though, I think only dictremove is needed here), it will not remove the XDictionary & associated Reactors and hence not truly disassociate the dimension until the user modifies the dimension in some way.

Lee
« Last Edit: July 05, 2012, 02:59:06 PM by Lee Mac »

BlackBox

  • King Gator
  • Posts: 3770
Re: associative dimentions, can i turn of associative in vlisp?
« Reply #12 on: July 05, 2012, 02:35:10 PM »
Be careful with yours, as although it deletes and removes the DIMASSOC Dictionary (though, I think only dictremove is needed here), it will not remove the XDictionary & associated Reactors and hence truly disassociate the dimension until the user modifies the dimension in some way.

I always appreciate constructive criticism; as I said above:

... Not really sure how to do this for existing Dimensions.

 :lol:
"How we think determines what we do, and what we do determines what we get."