New code works in ModelSpace, PaperSpace, Viewport, All dimensiontypes, Reverse mark. . .
Code:
(defun c:NoAsso (/ Space SelSet DimNr AssoNr NoAssoNr Ent EntDxf Index Item Legs ) ; *Redraw*
(if (not *Redraw* ) (setq *Redraw* 3 ) (if (= *Redraw* 3 ) (setq *Redraw* 4 ) (setq *Redraw* 3 )) )
(if (>= (getvar "CVPORT" ) 2 ) (setq Space "Model" ) (setq Space (getvar "CTAB" )) )
(if (setq SelSet (ssget "X" (list (cons -4 "<AND") (cons 0 "DIMENSION") (cons 410 Space ) (cons -4 "AND>"))) ) ;; Select all dimensions i CS
(progn
(setq DimNr 0 AssoNr 0 NoAssoNr 0 )
(while (setq Ent (ssname SelSet DimNr )) ;; Investigate all dimensions in the selectionset
(setq EntDxf (entget Ent ) )
(if (member '(102 . "{ACAD_REACTORS") EntDxf ) ;; Check for a reactor in present dimension
(progn
(setq Index 0 Item nil Legs nil )
(repeat (length EntDxf ) ;; Find the reactor in the dxfcode of present dimension
(if (equal (nth Index EntDxf ) '(102 . "{ACAD_REACTORS"))
(progn
(setq Item (cdr (nth (1+ Index ) EntDxf ))) ; When found, take next item
(setq Legs 0 )
(foreach Item_in (entget Item ) ;; Count asso points in present dimension
(if (equal Item_in '(1 . "AcDbOsnapPointRef")) (setq Legs (1+ Legs )) ( ) )
)
(cond
((and (< Legs 3 ) (member '(100 . "AcDb2LineAngularDimension") EntDxf )) (redraw Ent *Redraw* ) (setq NoAssoNr (1+ NoAssoNr )) )
((and (= Legs 1 ) (member '(100 . "AcDbRadialDimension" ) EntDxf )) (princ (strcat "\rASSO = " (itoa (setq AssoNr (1+ AssoNr ))))) )
((and (= Legs 1 ) (member '(100 . "AcDbDiametricDimension" ) EntDxf )) (princ (strcat "\rASSO = " (itoa (setq AssoNr (1+ AssoNr ))))) )
((and (= Legs 1 ) (member '(100 . "AcDbOrdinateDimension" ) EntDxf )) (princ (strcat "\rASSO = " (itoa (setq AssoNr (1+ AssoNr ))))) )
((and (= Legs 1 ) (member '(100 . "AcDbRadialDimensionLarge" ) EntDxf )) (princ (strcat "\rASSO = " (itoa (setq AssoNr (1+ AssoNr ))))) )
((= Legs 1 ) (redraw Ent *Redraw* ) (setq NoAssoNr (1+ NoAssoNr )) )
(t (princ (strcat "\rASSO = " (itoa (setq AssoNr (1+ AssoNr ))))) )
)
)
( )
)
(setq Index (1+ Index ) )
)
)
(progn
(redraw Ent *Redraw* ) ;; Reactor is missing, mark present dimension
(setq NoAssoNr (1+ NoAssoNr ))
)
)
(setq DimNr (1+ DimNr ) ) ;; Prepare for next dimension
)
(princ (strcat ", NoAsso = " (itoa NoAssoNr )) )
)
(princ ". . no dimension found in current space" )
)
(princ " . . run again [Enter] to reverse mark." )
(princ)
)
: ) Happy Computing !
kennet