Jump to content
Jean-Lévy Plante

Aligned Dimensions from a line to a perpendicular line, with centered text.

Recommended Posts

Jean-Lévy Plante

I would like to modify this lisp script so that the dimension has a centered text instead of on a side of the  dimension. But i don't know how.

(defun c:HD (/ HD_LineHouse HD_LineProperty HD_Point1 HD_BasePoint1 HD_Text1 HD_Point2 HD_BasePoint2 HD_Text2 HD_ActiveDoc HD_ActiveSpace)
   (if
      (and
         (setq HD_LineHouse    (car (entsel "\nSelect house line       : ")))
         (setq HD_LineProperty (car (entsel "\nSelect property boundary: ")))
         (= (vla-get-ObjectName (setq HD_LineHouse (vlax-ename->vla-object HD_LineHouse))) "AcDbLine")         
      )
      (progn       
         (setq HD_LineProperty (vlax-ename->vla-object HD_LineProperty))
         (if           
            (not (vl-catch-all-error-p (setq HD_Point1 (vl-catch-all-apply 'vlax-curve-getClosestPointTo (list HD_LineProperty (setq HD_BasePoint1 (vlax-safearray->list (vlax-variant-value (vla-get-StartPoint HD_LineHouse)))))))))
            (progn
               (setq HD_Point2 (vlax-curve-getClosestPointTo HD_LineProperty (setq HD_BasePoint2 (vlax-safearray->list (vlax-variant-value (vla-get-EndPoint   HD_LineHouse))))))
               (setq HD_Text1  (polar HD_Point1 (angle HD_BasePoint1 HD_Point1) 0))
               (setq HD_Text2  (polar HD_Point2 (angle HD_BasePoint2 HD_Point2) 0))
               (vla-StartUndoMark (setq HD_ActiveDoc (vla-get-ActiveDocument (vlax-get-acad-object))))
               (vla-put-TextPosition (vla-AddDimAligned (setq HD_ActiveSpace (vla-get-Block (vla-get-ActiveLayout HD_ActiveDoc))) (vlax-3d-point HD_BasePoint1) (vlax-3d-point HD_Point1) (vlax-3d-point HD_Point1)) (vlax-3d-point HD_Text1))
               (vla-put-TextPosition (vla-AddDimAligned       HD_ActiveSpace                                                      (vlax-3d-point HD_BasePoint2) (vlax-3d-point HD_Point2) (vlax-3d-point HD_Point2)) (vlax-3d-point HD_Text2))
               (vla-EndUndoMark HD_ActiveDoc)
               (mapcar 'vlax-release-object (list HD_ActiveSpace HD_ActiveDoc))
            )
         )
      )
   )
   (princ)
)    

HD-Automatic Dimension.LSP

Share this post


Link to post
Share on other sites
hanhphuc
               (setq HD_Text1  (polar HD_Point1 (angle HD_Point1 HD_BasePoint1) (* 0.5 (distance HD_BasePoint1 HD_Point1))))
               (setq HD_Text2  (polar HD_Point2 (angle HD_Point2 HD_BasePoint2) (* 0.5 (distance HD_BasePoint2 HD_Point1))))

your polar function distance=0, try change to half i.e: distance between 2 points

Share this post


Link to post
Share on other sites
Jean-Lévy Plante

Thanks it worked :) 

Share this post


Link to post
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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