Jump to content

LISP for Dimensioning from Multiple Points to Line


Recommended Posts

Posted

Here is a start for you, change the line to a dim command, next step is to pick all points and do in one go. Please have a go at modifying.

 

(setq oldsnap (getvar 'osmode))
(setq obj (vlax-ename->vla-object (car (entsel "\nPick line object"))))

(while
(setq pt (getpoint "pick point"))
(setq pt2 (vlax-curve-getClosestPointTo obj pt acextendnone))
(setvar 'osmode 0)
(command "line" pt pt2 "")
(setvar 'osmode oldsnap)
)

Posted

Hi BIGAL,

 

Thank you for your reply. However I have no background on LISP Programming.

I have tried my best to modify by changing the line to dim command as below. Still couldn't get it working though. Would you mind pointing out where went wrong?

(defun c:try2 ()



(setq oldsnap (getvar 'osmode))

(setq obj (vlax-ename->vla-object (car (entsel "\nPick line object"))))



(while

(setq pt (getpoint "pick point"))

(setq pt2 (vlax-curve-getClosestPointTo obj pt acextendnone))

(setvar 'osmode 0)

(command ".DIMLINEAR" pt pt2 "")

(setvar 'osmode oldsnap)

)

)

 

Posted

Very simple fix dim expects an offset point so

 

(command ".DIMLINEAR" pt pt2 pt )

  • 8 years later...
Posted

auto dimensioning by selecting multiple points and one line object

Posted
3 hours ago, Kumar1 said:

auto dimensioning by selecting multiple points and one line object

@Kumar1 please upload a sample.dwg with, at least, 2 o3 dim as you need it to be 

 

 

Posted
On 10/17/2017 at 3:00 PM, comet712 said:

Thanks BIGAL! :)

this lisp is fine, but instead of picking each point, can we write a lisp routine to select multiple points and write dimension automatically.

Posted
18 hours ago, devitg said:

@Kumar1 please upload a sample.dwg with, at least, 2 o3 dim as you need it to be 

 

 

this lisp is fine, but instead of picking each point, can we write a lisp routine to select multiple points and write dimension automatically. Sample File uploaded above.

Posted
5 hours ago, Kumar1 said:

this lisp is fine, but instead of picking each point, can we write a lisp routine to select multiple points and write dimension automatically. Sample File uploaded above.

@Kumar1 please make or send  a real dwg , with  points-layer, line-layer, dim-layer and a new dimstyle not an overrided style, so all variables system are stated . Like the first DWG posted  at this topic Dimension from Point to line.dwg

not the same dim style.png

Posted (edited)

Here is a boiled down simple version with no error testing. It assumes that the dimensions will run on the same angle as the angle between the point and the curve segment:

;; Created by P. Kenewell 1/22/2026
(defun c:dim2pts (/ ep i p1 p2 p3 ss)
   (if
     (and
        (progn
           (princ "\nSelect Points to Dimension: ")
           (setq ss (ssget '((0 . "POINT"))))
        )
        (setq ep (entsel "\nSelect a curve to Dimension to: "))
     )
     (repeat (setq i (sslength ss))
        (setq p1 (cdr (assoc 10 (entget (ssname ss (setq i (1- i))))))
              p2 (vlax-curve-getclosestpointto (vlax-ename->vla-object (car ep)) p1)
              p3 (polar p1 (angle p1 p2) (/ (distance p1 p2) 2))
        )
        (command "._dimrotated" (* (/ (angle p1 p2) pi) 180.0) "_non" p1 "_non" p2 "_non" p3)
     )
   )
   (princ)
)

Example Screenshots:

image.png.084e7ce2294d792f366d446f8dec3765.png

 

image.png.90d302fe22b407091e1f7cdde019298d.png

 

image.png.48045bd3ee17dd08cf3c14f21abe6ffc.png

 

 

 

Edited by pkenewell
Removed unnecessary (progn...)

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