Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp to Reassociate Baseline Dimensions

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
akaterr55
1495 Views, 7 Replies

Lisp to Reassociate Baseline Dimensions

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

Labels (3)
7 REPLIES 7
Message 2 of 8
ВeekeeCZ
in reply to: akaterr55

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...

 

 

Message 3 of 8
ВeekeeCZ
in reply to: ВeekeeCZ

Sorry, I was about to add an image... but the site is totally screwed.
Message 4 of 8
akaterr55
in reply to: ВeekeeCZ

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.

Message 5 of 8
ВeekeeCZ
in reply to: akaterr55

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)
  )

 

Message 6 of 8
ВeekeeCZ
in reply to: ВeekeeCZ

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)
  )

 

Message 7 of 8
akaterr55
in reply to: ВeekeeCZ

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 !!!

Message 8 of 8
ВeekeeCZ
in reply to: akaterr55

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta