Lisp to Reassociate Baseline Dimensions

akaterr55
Advocate
Advocate

Lisp to Reassociate Baseline Dimensions

akaterr55
Advocate
Advocate

Hi Everyone,

 

There probably already exists a lisp to do exactly what I'm looking for, but I've yet to find it.

 

In a nutshell, I'd like to have the user pick the "Base" dimension, then using whatever selection method, pick the dimensions that are dependent to that one, and have their Point 1's all associate with the same Point 1 of the base dimension.

 

My try at it has the user zoom in and select the Actual Point, then individually pick each of the baseline dimensions to reassociate them.  It's Better than doing it all manually, but still a little bit tedious.

 

I'm attaching a sample drawing with some notations to illustrate what we've got, and my little lisp that actually works, it's just not exactly super-efficient.

 

Thanks for any help!

-Mark

0 Likes
Reply
Accepted solutions (1)
1,718 Views
7 Replies
Replies (7)

ВeekeeCZ
Consultant
Consultant

Not that I have a solution or about to have...

 

Just out of curiosity... what sort of base point are your dims of your "template" associated with? The red circle. This seems off from the beginning...

 

 

0 Likes

ВeekeeCZ
Consultant
Consultant
Sorry, I was about to add an image... but the site is totally screwed.
0 Likes

akaterr55
Advocate
Advocate

Yes, it they are all off (from the finished part dimension).  These are baseline dimensions from the end of the cut piece part.

 

There is actually a pair of lines "buried" beneath the printed lines.  The bottom one can be seen sticking out from behind the radius of that angle iron.  I just put the circle in there to draw attention down to the point in question.

 

That dimension you're asking about (Point 1) is attached to the left end of the upper one that is obscured. 

 

Point 2 for it and for all the others are attached to the top end of the hole center lines.

0 Likes

ВeekeeCZ
Consultant
Consultant

Seems to be working...

 

(defun c:BDX ( / s b p i e)

  (princ "\nSelect dims to be associated... ")
  (if (and (setq s (ssget "_:L" '((0 . "DIMENSION"))))
	   (setq b (car (entsel "\nPick a Base Dim: ")))
	   (or (= "DIMENSION" (cdr (assoc 0 (entget b))))
	       (prompt "Error: Wrond entity, need Base Dimension. "))
	   (setq p (cdr (assoc 13 (entget b))))
	   )
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (command "dimreassociate" e "" p "")))
  (princ)
  )

 

ВeekeeCZ
Consultant
Consultant
Accepted solution

Hmm.. added "_end" osnap point, seems to be working better.

Also added feedback to the user - dims not fully associated remains in the selection set highlighted.

 

(defun c:BDX ( / s b p i e)
  
  ; by Vl. Michl CADStudio
  ; returns nil or assoc point number (1, 2, 3=both)
  
  (defun isDimAssoc? (diment / elst dict)
    (and (setq elst (entget diment))
	 (setq dict (cdr (assoc 360 elst)))
	 (setq elst (entget dict))
	 (setq elst (entget (cdr (assoc 360 elst)))))
    (cdr (assoc 90 elst)))
  
  ; ------------------------------------------------------
  
  (princ "\nSelect dims to be associated... ")
  (setq m (ssget "_I" '((0 . "DIMENSION"))))

  (if (and (setq s (ssget "_:L" '((0 . "DIMENSION"))))
	   (setq b (car (entsel "\nPick a Base Dim: ")))
	   (or (= "DIMENSION" (cdr (assoc 0 (entget b))))
	       (prompt "Error: Wrond entity, need Base Dimension. "))
	   (setq p (cdr (assoc 13 (entget b))))
	   )
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (command "_.dimreassociate" e "" "_end" p "")
      (if (= 3 (isDimAssoc? e))
	(ssdel e s))))
  (if m (sssetfirst nil nil))
  (if (and s (not (zerop (sslength s))))
    (sssetfirst nil s))
  
  (princ)
  )

 

akaterr55
Advocate
Advocate

Perfect!  Way to go, Z !!

 

Just Curious, which release are you running?  We have a mix of 2015 thru 2020 here.  Mine is 2015 and a cube mate here has 2018 both my crude and your awesome lisp works on both those machines.  but a couple 2018's here just won't do it with either.  Keeps saying point not reassociated on that point 1.  Has to be some setting.

 

Thanks again Z !!!

0 Likes

ВeekeeCZ
Consultant
Consultant

It's C3D 2020 as ACAD.

Also made a quick try in 2018, also good.

 

In general, make sure that the base dim stays on the screen. And since its OSNAPs, check APERTURE and similar setting.

Also can thy to add (initcommandversion) prior to the dimreas line - sure just in case that the command works when done manually, but not by the program.

Good luck.

0 Likes