Jump to content

How to modify this lisp to correct dim distance when there are more than 1 dimension from the object.


Recommended Posts

Posted

These two pictures below is a before and after for an object that has only 1 dimension. It successfully change the distance from 100 to 200.

1.PNG.5f2feb26fd25e30efe706350f8db80f8.PNG  2.PNG.145997ed7e8c3e8a0b7b8ed685090db2.PNG

 

 

But on this different plate with 1st and 2nd dimension. Somehow the outcome is what is not desired/expected, which is to keep the distance of the 1st dimension from the 2nd and only affect the 2nd dimension as the max value from the dim distance input.

 

3.PNG.de2e9dde0324ac11692521d5aec5935c.PNG4.PNG.932b8c389969ffcbc30be49a500b148d.PNG

 

 

Code by exceed from this thread:

(defun c:DLA ( / sel ent txp al ar mp uALR s txpp uvt tp exss exssent exssl exssindex)
(defun deg2rad (ang / )
  (/ (* PI ang) 180.0)
)

(defun rad2deg ( ang / )
  (/ (* 180.0 ang) PI)
)

;; midpoint of 2 given points
(defun mid ( pt1 pt2 / )
  (mapcar '(lambda (x y) (+ (* 0.5 x) (* 0.5 y)))
  pt1
  pt2
  )
)
;;;  Calculate unit vector of vector a 
(defun uvec 
  (a / d)
  (setq	d (distance '(0 0 0) a)
	a (mapcar '/ a (list d d d))
  )
)
; Compute the dot product of 2 vectors a and b
(defun dot ( a b / dd)
  (setq dd (mapcar '* a b))
  (setq dd (+ (nth 0 dd) (nth 1 dd) (nth 2 dd)))
)					;end of dot  

  (princ "\nDistance DIM: ")
  (setq dist (getreal))
  
  (princ "\nSelect DIM: ")                                    
(setq exss (ssget '((0 . "*dim*"))))                           
(setq exssl (sslength exss))                                   
(setq exssindex 0)                                             
(repeat exssl                                                    
 (setq exssent (entget (ssname exss exssindex)))              

 (setq ent (cdr (car exssent)))                                 
 (setq txp (cdr (assoc 10 (entget ent))))
 (setq al (cdr (assoc 13 (entget ent))))
 (setq ar (cdr (assoc 14 (entget ent))))

 (setq mp (mapcar '/
             (mapcar '+ al ar)
	 '(2. 2. 2.)
	 )
 )

; uALR = unit vector from al to ar
(setq uALR (uvec (mapcar '- ar al)))
(setq s (dot uALR (mapcar '- txp al)))
; txpp = projection of txp onto the line    
(setq txpp
       (mapcar '+ al (mapcar '* uALR (list s s s)))
)
(setq uvt (uvec (mapcar '- txp txpp)))
(setq tp (mapcar '+ mp (mapcar '* uvt (list dist dist dist))))
(entmod
  (subst (cons 10 tp) (assoc 10 (entget ent)) (entget ent))
)
(entmod
  (subst (cons 11 tp) (assoc 11 (entget ent)) (entget ent))
)
;)                                            while delted
 (setq exssindex (+ exssindex 1))     for repeat added
)                                            for repeat added
  (princ)
)

 

 

 

 

 

Posted
7 hours ago, AeJay said:

These two pictures below is a before and after

It is a picture , not a dwg . 

AFIK , ACAD can not edit pictures.

Please upload your sample.DWG 

 

Posted

This is being asked for over at forums/autodesk, its about resetting the dim offset from the object, say current dim offst is 10 but want 12.5. There was an answer plays with the dxf 13 & 14 codes.

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