Jump to content

Select non-associative DIMENSIONS ?


3dwannab

Recommended Posts

Hi,

 

I've tried to look into the differences between DIMS that need to be reassociated and actual associative DIMS.

 

All I can see is that there are two pairs in the DXF 330 listing.

 

Like the '(1 . "AcDbOsnapPointRef")' for example.

 

I'm scratching my head and haven't found a way to do it.

 

I've tried:

(setq ss_1 (ssget (list (cons 0 "DIMENSION")(cons 102 "{ACAD_REACTORS"))))

 

But that gets the DIMS that are still not ASSOC. That's probably just the got to do with the DIM style.

 

I know I can use the DIMREASSOCIATE command followed by D but I be zooming in and out like a fiddlers elbow. ACAD doesn't seem to group them close to each other by doing this.

 

Non-ASSOC DIM

(-1 . <Entity name: 26849003940>)
(0 . "DIMASSOC")
(5 . "334A4")
(102 . "{ACAD_REACTORS")
(330 . <Entity name: 26849003830>)
(102 . "}")
(330 . <Entity name: 26849003830>)
(100 . "AcDbDimAssoc")
(330 . <Entity name: 26849003820>)
(90 . 2)
(70 . 1)
(71 . 0)
(1 . "AcDbOsnapPointRef")
(72 . 1)
(331 . <Entity name: 267c7f5bb40>)
(331 . <Entity name: 2678711a950>)
(73 . 2)
(91 . 3)
(301 . "32246")
(301 . "2DE5D")
(40 . 1.0)
(10 0.0 0.0 2.0e+50)
(75 . 0)

 

ASSOC DIM

(-1 . <Entity name: 26849003ad0>)
(0 . "DIMASSOC")
(5 . "334BD")
(102 . "{ACAD_REACTORS")
(330 . <Entity name: 26849003990>)
(102 . "}")
(330 . <Entity name: 26849003990>)
(100 . "AcDbDimAssoc")
(330 . <Entity name: 26849003980>)
(90 . 3)
(70 . 1)
(71 . 0)
(1 . "AcDbOsnapPointRef")
(72 . 1)
(331 . <Entity name: 267c7f5bb40>)
(331 . <Entity name: 2678711a950>)
(73 . 2)
(91 . 3)
(301 . "32246")
(301 . "2DE5D")
(40 . 1.0)
(10 0.0 0.0 2.0e+50)
(75 . 0)
(1 . "AcDbOsnapPointRef")
(72 . 1)
(331 . <Entity name: 267c7f5bb40>)
(331 . <Entity name: 2678711a950>)
(73 . 2)
(91 . 2)
(301 . "32246")
(301 . "2DE5D")
(40 . 1.0)
(10 0.0 0.0 2.0e+50)
(75 . 0)

Link to comment
Share on other sites

This works fine on BricsCAD:

(defun c:DimNonAssocSel ( / ss)
 (if
   (setq ss
     (ssget
       "_A"
       (append
         (if (= 1 (getvar 'cvport))
           (list (cons 410 (getvar 'ctab)))
           '((410 . "Model"))
         )
         '(
           (0 . "*DIMENSION") ; Also catches "ARC_DIMENSION".
           (-4 . "<OR")
             (-4 . "<NOT")
               (102 . "{ACAD_REACTORS") 
             (-4 . "NOT>")
             (-4 . "<NOT") 
               (102 . "{ACAD_XDICTIONARY")
             (-4 . "NOT>")
           (-4 . "OR>")
         )
       )
     )
   )
   (sssetfirst nil ss)
 )
 (princ)
)

Originally posted here:

https://forum.bricsys.com/discussion/27010/how-do-i-determine-if-a-paper-space-dimension-is-associated-with-the-object

Link to comment
Share on other sites

This works fine on BricsCAD:

 

Thanks Roy.

 

It works for DIMS that have 0 of their points ASSOC but not if one point is ASSOC.

 

For the DIM with one of it's point ASSOC, it's DXF data shows {ACAD_REACTORS & {ACADXDICTIONARY meaning they're still associate but only with one of their points.

 

I found that these are got by looking at the 330 code data with 90 pair displaying the ASSOC value. (I'm still not sure how to access that, but)

 

That's what the sub-routine gets that I found in my existing LISPs I have.

 

It returns:

;; 1 if first dimension point is associative
;; 2 if second dimension point is associative
;; 3 if both points are associative
;; nil if the dimension is not associative

 

I'm actually not sure if I should use it or post the code. I'll try get in touch with Joe Burke but AFAIK he has vanished from forum activity.

The best thing about it is that it will even get the DIMs that ACAD think are ASSOC but they're not.

 

I was frustrated trying to get it to select only the DIMs with the ! symbol. But low and behold. A close of the drawing and a reopen, y voila, an exclamation mark at the DIMs that ACAD had previously said were grand.

 

The power of LISP eh!!

Link to comment
Share on other sites

Here's my code minus the sub-routine for the get DXF 90 group.

 

(defun c:QSDIMS_ASSOC ( / ss_1 e i )
(if	(setq ss_1 (ssget '((0 . "*DIMENSION,MULTILEADER"))))
	(progn
		(repeat (setq i (sslength ss_1))
			(setq i (1- i))
			(if
				(= 3 (DimAssoc (setq e (ssname ss_1 i))))
				(SSDEL e ss_1 )
				)
			)
		(command ".dimreassociate" SS_1 "")
		(princ (strcat "\n: -------------------------\n   >>>   " (itoa (setq len (sslength ss_1))) (if (> len 1) " DIS-ASSOCIATED Dimensions (including leaders)" " DIS-ASSOCIATED Dimension / leader") " found. Now RE-ASSOCIATE   <<<   \n: -------------------------\n"))
		)
	(princ "\n: -------------------------\n   ***  Nothing Selected  ***   \n: -------------------------\n")
	)
(setq ss_1 nil)
(princ)
)

Edited by 3dwannab
Added DIMREASSOCIATE command
Link to comment
Share on other sites

Sorry Roy, but you tell me why the sssgetfirst is not working in the code. I've added the DimAssoc sub-fn.

 

I think that Joe Burke wouldn't mind me posting the code. After all, it's 10 lines.

Hopefully he doesn't. It came from his Superflatten script and it mentions no EULA.

 

But full credit to him (Joe Burke).

 

;;----------------------------------------------------------------------;;
;; QSDIMS_ASSOC
;; Credit to Joe Burke for DimAssoc fn.
;; Selects all DIMENSIONs & MULTILEADERs where they're non-associated.
;; CADTutor thread post: http://www.cadtutor.net/forum/showthread.php?104868-Select-non-associative-DIMENSIONS&p=706025&viewfull=1#post706025

(defun c:QSDIMS_ASSOC ( / *error* ss_1 e i )

(defun *error* (errmsg)
	(and acDoc (vla-EndUndoMark acDoc))
	(and errmsg
		(not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*"))
		(princ (strcat "\n<< Error: " errmsg " >>\n"))
		)
	(setvar 'autosnap		var_autosnap)
	(setvar 'cmdecho		var_cmdecho)
	(setvar 'osmode			var_osmode)
	(setvar 'snapmode		var_snapmode)
	)

(setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc))

(setq
	var_autosnap	(getvar 'autosnap)
	var_cmdecho		(getvar 'cmdecho)
	var_osmode		(getvar 'osmode)
	var_snapmode	(getvar 'snapmode)
	)

(setvar 'autosnap		1)
(setvar 'cmdecho		0)
(setvar 'osmode			7) ; 7 = Endpoint, midpoint & center.
(setvar 'snapmode		3)

(progn
	(if	(setq ss_1 (ssget '((0 . "*DIMENSION,MULTILEADER"))))
		(progn
			(repeat (setq i (sslength ss_1))
				(setq i (1- i))
				(if
					(or
						(= 3 (DimAssoc (setq e (ssname ss_1 i))))
						(and
							(= "{ACAD_XDICTIONARY" (cdr (assoc 102 (entget (setq e (ssname ss_1 i))))))
							(= "MULTILEADER" (cdr (assoc 0 (entget (setq e (ssname ss_1 i))))))
							)
						)
					(ssdel e ss_1)
					)
				)
			(command "._dimreASSociate" ss_1 "")
			)
		(princ "\n: -------------------------\n   ***  Nothing Selected  ***   \n: -------------------------\n")
		)
	)

(if (< 0 (sslength ss_1))
	(progn
		(princ (strcat "\n: -------------------------\n   >>>   " (itoa (setq len (sslength ss_1))) (if (> len 1) " dis-ASSociated Dimensions (including leaders)" " dis-ASSociated Dimension / leader") " found, please RE-ASSOCIATE.   <<<   \n: -------------------------\n"))
		(sssetfirst nil ss_1)
		)
	(princ "\n: -------------------------\n   ***  Nothing needs re-ASSociatating  ***   \n: -------------------------\n")
	)

(setq ss_1 nil)
(*error* nil)
(vl-load-com) (princ)

) ;; end QSDIMS_ASSOC

;;----------------------------------------------------------------------;;
;; SUB-FUNCTIONS START
;;----------------------------------------------------------------------;;

;;----------------------------------------------------------------------;;
;; DIMASSOC - by Joe Burke
;; Not currently used.
;; Argument: the ename of a dimension
;; Example given a rotated or aligned dimension
;; Returns: 1 if first dimension point is associative
;;          2 if second dimension point is associative
;;          3 if both points are associative
;;          nil if the dimension is not associative
;; Note: the value returned is the bitsum of the associativity flag.
;; 1 = First point reference
;; 2 = Second point reference
;; 4 = Third point reference
;; 8 = Fourth point reference

(defun DimAssoc (dim / elst dict)
(if (= (type dim) 'VLA-OBJECT)
	(setq dim (vlax-vla-object->ename dim))
	)
(and
	(setq elst (entget dim))
  (setq dict (cdr (assoc 360 elst))) ;dictionary ename
  (setq elst (entget dict))
  (setq elst (entget (cdr (assoc 360 elst)))) ;DIMASSOC elst
  )
(cdr (assoc 90 elst))
)

Edited by 3dwannab
fixed snap bug
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...