Jump to content

Recommended Posts

Posted

I am attempting to change the text movement after I place a continuous dimension to move the dimension line with dimension text. I assume that I need to set the variable dimtmove to 0 for the dimension but I'm not sure if that is even the correct approach. I thought I remembered seeing something similar to this but alas I could find the link again. Any help would be greatly appreciated.

 

(defun c:cdim ( / pt1 pt2)
;This function allows the user to dimension continuously and then after they are done insert the overall distance

(command "dimlinear" pause pause pause);start the first dimension
(setq pt1 (cdr (assoc 13(entget (entlast)))));get the start point
(command "dimcontinue");dimension everything in between start and end

(while (/= (getvar "CMDACTIVE") 0);keep the dimcontinue going until user exits

(command pause)
(setq obj (vlax-ename->vla-object (car (entsel (entlast)))));start here to try and change dimtmove
(vlax-put obj 'Dimtmove 0)
)
(setq pt2 (cdr (assoc 14(entget (entlast)))));get end point from last dimcontinue inserted
(command "dimlinear" pt1 pt2 pause);place the overall dimension
)

Posted

Thanks. :)

 

It is very close but for some reason all continue dimensions except the last one are deleted after the next point is selected. I guess I could get the entity names in the while loop and then after exiting the while loop start another loop to change them but surely there is a more straight forward way.

Posted

Welcome to cadTutor :)

 

Try this instead and hope you like it ...

 

(defun c:cdim (/ pt1 pt2 e p pt obj)
 (command "_.dimlinear" pause pause pause)
 (if (eq (cdr (assoc 0 (setq e (entget (entlast))))) "DIMENSION")
   (setq pt1 (cdr (assoc 13 e))
         pt  (cdr (assoc 14 e))
   )
 )
 (while (setq p (getpoint pt "\n Specify next point :"))
   (command "_.dimlinear"
            "_none"
            pt
            "_none"
            p
            (cdr (assoc 10 e))
   )
   (vlax-put (vlax-ename->vla-object (setq obj (entlast)))
             'textmovement
             0
   )
   (setq pt (cdr (assoc 14 (entget obj))))
 )
 (setq pt2 (cdr (assoc 14 (entget obj))))
 (command "_.dimlinear" "_none" pt1 "_none" pt2 pause)
)

Posted

I actually thought to try it that way too using only the dimlinear command and then offsetting the dimension using the first text offset point but you can't keep using the first text point because the dimension will extend in the shortest distance to the point so you could end up with something as shown below. I don't know that I would run into this situation much but for the sake of it being versatile I want to prevent this.

Image 001.png

Posted

OK I figured it out mostly. All that was need was a regen at the end. I would like the regen to happen after each continue dimension is placed but I will accept it for now until I have more than a couple days experience with auto/visual lisp

 

(defun c:cdim (/ pt1 pt2 doc )
;This function allows the user to dimension continuously and then after they are done insert the overall distance
(vl-load-com);load visual lisp


(setq doc (vla-get-ActiveDocument(vlax-get-acad-object)))
   (vla-put-ActiveUCS doc(vla-add (vla-get-usercoordinatesystems doc) (vlax-3D-point '(0. 0. 0.)) (vlax-3D-point '(1. 0. 0.))
         (vlax-3D-point '(0. 1. 0.)) "TempWorld_UCS"))
(command "_UCS" "NA" "r" "TempWorld_UCS")
;change the UCS to world so the final dimension will insert correctly




(command "dimlinear" pause pause pause);start the first dimension
(setq pt1 (cdr (assoc 13(entget (entlast)))));get the start point
(command "dimcontinue");dimension everything in between start and end

(while (/= (getvar "CMDACTIVE") 0);keep the dimcontinue going until user exits
(command pause)
(vlax-put (vlax-ename->vla-object (setq obj (entlast))) 'textmovement 0)


)
	(command "regen")
	(setq pt2 (cdr (assoc 14(entget (entlast)))));get end point from last dimcontinue inserted
	(command "dimlinear" pt1 pt2 pause);place the overall dimension	

   

)

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