non associative dimension to associative

non associative dimension to associative

dani-perez
Advocate Advocate
1,989 Views
11 Replies
Message 1 of 12

non associative dimension to associative

dani-perez
Advocate
Advocate

Hello all,

 

I am trying to associate thounsand of dimensions at once. all the dimensions are already made, so I dont know how reassociate then at once.

 

Any ideas?

 

Thanks all.

0 Likes
Accepted solutions (1)
1,990 Views
11 Replies
Replies (11)
Message 2 of 12

ВeekeeCZ
Consultant
Consultant

Have you tried the DIMREASSOCIATE command? You can select multiple dimensions.

 

Try is something like this is working for you.

(defun c:DimReassociateMultiple (/ ss)

  (if (and (setq ss (ssget '((0 . "DIMENSION"))))
           (vl-cmdf "_.DIMREASSOCIATE" ss "")
           )
    (while (> (getvar 'cmdactive) 0)
      (command "")))
  (princ)
  )
0 Likes
Message 3 of 12

dani-perez
Advocate
Advocate

Hello 

 thanks for replying.

 

Yes, I tried "DIMREASSOCIATE" and "multiple" option. But The dimensions dont turn into associative to a line or pline for example.

 

I Tried the code and didnt work either.

0 Likes
Message 4 of 12

ВeekeeCZ
Consultant
Consultant

Yeah, nor for me. I have no idea how this command works - what is this <next> option good for?! 

 

Anyway. Here is upgraded version which works for Aligned and Rotated dimensions. Hope that helps.

 

(defun c:DimReassociateMultiple (/ ss i ent p13 p14)

  (if (setq ss (ssget '((0 . "DIMENSION"))))
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (if (and (vl-position (cdr (assoc 100 (reverse (entget ent)))) '("AcDbAlignedDimension" "AcDbRotatedDimension"))
	       (setq p13 (cdr (assoc 13 (entget ent))))
	       (setq p14 (cdr (assoc 14 (entget ent))))
	       )
	(command "_.DIMREASSOCIATE" ent "" "_end,_mid" p13 "_end,_mid" p14))))
  (princ)
  )
0 Likes
Message 5 of 12

dani-perez
Advocate
Advocate

Hello 

 

 

 

 

0 Likes
Message 6 of 12

ВeekeeCZ
Consultant
Consultant
Accepted solution

Dani, it would be really helpful if you learn something about the issue. Maybe THIS help article can shine some light.

 

It's a really complex issue with various possibilities. I tried to solve the most simple task when associativity is defined by end or mid points of objects. I know that won't solve the issue entirely by far. But that's all I can offer upon this issue. 

Message 7 of 12

dani-perez
Advocate
Advocate

Hello  

 

 

 

0 Likes
Message 8 of 12

etrotterQ4J78
Participant
Participant

Dont Know if you have realized but the code works for center and quadrant if you add them in for each point as well.

Message 9 of 12

etrotterQ4J78
Participant
Participant

Do you know how to improve this one I modified from your code for Leaders? It doesnt seem to want to reassociate them unless I zoom in. About forgot to add in regards to the zooming in the problem is I can only reassociate 1 or 2 at a time when I zoom in the goal is to use a crossing window and get them all to do it at once.

(defun c:LMU (/ ss i ent p13)
 
  (if (setq ss (ssget '((0 . "LEADER"))))
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (if (and (vl-position (cdr (assoc 100 (reverse (entget ent)))) '("AcDbLeader"))
       (setq p13 (cdr (assoc 10 (entget ent))))
       )
(command "cmdecho" "0" "_.DIMREASSOCIATE" ent "" "_NEAREST" p13 "cmdecho" "1"))))
  (princ)
  )
0 Likes
Message 10 of 12

ВeekeeCZ
Consultant
Consultant

Well, the limit is the nearest osnap mode and its outreach. That is defined by APERTURE sysvar. Also can add zoom in to each leader to the routine.

Another option is to select all potential targets (say lying within your crossing window) and find the closest point of the closest entity to each leader.

 

Message 11 of 12

etrotterQ4J78
Participant
Participant

Setting the aperture variable in the code worked like a charm thanks for the help.

0 Likes
Message 12 of 12

etrotterQ4J78
Participant
Participant

Good morning, I believe I need a little help here I'm trying to add an if statement to your dimension code and when

I do it returns bad argument type: lselsetp nil. I believe the solution maybe something I'm not seeing or maybe

it's not applicable with this type of code I'm pretty new to lisp but I think the error means selection set is nil

somewhere in the meantime I'm going to keep trying to figure it out, but this is what I've added so far. The statement is something I've borrowed from another code and what it did in that code is it didn't try to reassociate dimensions

that were already associated with objects.

 

(defun c:DMU (/ ss i ent p13 p14)
 
  (if (setq ss (ssget '((0 . "DIMENSION"))))
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (if (and (vl-position (cdr (assoc 100 (reverse (entget ent)))) '("AcDbAlignedDimension" "AcDbRotatedDimension" "AcDbOrdinateDimension"))
       (setq p13 (cdr (assoc 13 (entget ent))))
       (setq p14 (cdr (assoc 14 (entget ent))))
       )
(command "cmdecho" "0" "pickbox" "1" "_.DIMREASSOCIATE" "ss" ent "" "_end,_mid,_quadrant,_center" p13 "_end,_mid,_quadrant,_center" p14 "pickbox" "6" "cmdecho" "1"))))
  (princ)
  )
 
(if (< 0 (sslength ss))
(progn
(princ (strcat "\n: -------------------------\n   >>>   " (itoa (setq len (sslength ss))) (if (> len 1) " dis-ASSociated Dimensions" " dis-ASSociated Dimension") " found, please RE-ASSOCIATE.   <<<   \n: -------------------------\n"))
(sssetfirst nil ss)
)
(princ "\n: -------------------------\n   ***  Nothing needs re-ASSociatating  ***   \n: -------------------------\n")
)
 
(setq ss nil)
(*error* nil)
(vl-load-com) (princ)
0 Likes