Jump to content

distance from polyline points to a reference line!!???


Recommended Posts

Posted

Hello to everyone! Can you please help me with a lsp program that automaticaly generate linear dimensions from the points of a polyline to a reference line, because with the classic comand (dimlinear) i can draw the dimension line each point at a time. I attached an dwg for you to understand better. Excuse my english please!

 

Thanks!

distance from polyline points to a reference line.dwg

Posted

Try this:

(defun c:DimTwo(/ aDoc Space pl ReFL pt pt2 ss)
 (vl-load-com)
 (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
 (setq Space
 (if (= 1 (getvar "CVPORT"))
   (vla-get-PaperSpace aDoc)
   (vla-get-ModelSpace aDoc)
 )
 )
 (prompt "\nSelect Polyline:")
 (if (and
(setq Pl (ssget ":E:S:L" '((0 . "LWPOLYLINE"))))
(progn (prompt "\nSelect Reference Line:")
       (setq RefL (ssget ":E:S:L" '((0 . "*LINE"))))
)
     )
   (progn
     (setq RefL (vlax-ename->vla-object (ssname RefL 0)))
     (foreach pt (mapcar
     'cdr
     (vl-remove-if-not
       '(lambda (x) (= (car x) 10))
       (entget (ssname pl 0))
     )
   )
(vla-addDimRotated
  space
  (vlax-3d-point (append pt '(0.0)))
  (vlax-3d-point
    (setq pt2 (vlax-curve-getclosestpointto RefL pt))
  )
  (vlax-3d-point
    (mapcar (function (lambda (a b) (/ (+ a b) 2.))) pt pt2)
  )
  1.57079633
)
     )
   )
 )(princ)
)

 

Hope this helps

Posted
It work well! Thank you very much!

 

You're welcome jhonnying

Glad it worked for you.

 

Cheers

Posted
Try this:

(defun c:DimTwo(/ aDoc Space pl ReFL pt pt2 ss)
 (vl-load-com)
 (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
 (setq Space
 (if (= 1 (getvar "CVPORT"))
   (vla-get-PaperSpace aDoc)
   (vla-get-ModelSpace aDoc)
 )
 )
 (prompt "\nSelect Polyline:")
 (if (and
(setq Pl (ssget ":E:S:L" '((0 . "LWPOLYLINE"))))
(progn (prompt "\nSelect Reference Line:")
       (setq RefL (ssget ":E:S:L" '((0 . "*LINE"))))
)
     )
   (progn
     (setq RefL (vlax-ename->vla-object (ssname RefL 0)))
     (foreach pt (mapcar
     'cdr
     (vl-remove-if-not
       '(lambda (x) (= (car x) 10))
       (entget (ssname pl 0))
     )
   )
(vla-addDimRotated
  space
  (vlax-3d-point (append pt '(0.0)))
  (vlax-3d-point
    (setq pt2 (vlax-curve-getclosestpointto RefL pt))
  )
  (vlax-3d-point
    (mapcar (function (lambda (a b) (/ (+ a b) 2.))) pt pt2)
  )
  1.57079633
)
     )
   )
 )(princ)
)

 

Hope this helps

 

Hello!

Can someone help me?

In Lisp, this brings me the following error message:

 

"Incorrect string ssget mode"

 

Thank you for your help!

 

Martin

Posted

(ssget "_:E:S:L" '((0 . "LWPOLYLINE"))));

 

Not sure though :unsure:

Posted
(ssget "_:E:S:L" '((0 . "LWPOLYLINE"))));

 

Not sure though :unsure:

That would be my guess, since the OP's location is Austria.

Posted

Unfortunately, no. The error persists.

Error message: Select Reference Line: with error: Incorrect string ssget mode

 

Best regards Martin

Posted

I'd be interested to read the available SSGET modes for the Austrian acad*dev.chm

Posted

Could this be modified to also work with horizontal distances? Ie the reference line is vertical.

Cheers

Posted
Could this be modified to also work with horizontal distances? Ie the reference line is vertical.

Cheers

 

Replace 0 to 1.57079633

 

 

 

.............................
.............................
.............................
  (vlax-3d-point
    (mapcar (function (lambda (a b) (/ (+ a b) 2.))) pt pt2)
  )
  [b]0[/b]
)
     )
   )
 )(princ)
)

Posted
Unfortunately, no. The error persists.

Error message: Select Reference Line: with error: Incorrect string ssget mode

 

Best regards Martin

 

You "think" you may have to do the same for

(setq RefL (ssget "_:E:S:L" '((0 . "*LINE"))));

 

Since the error this time comes after the Polyline is selected

Posted
Could this be modified to also work with horizontal distances? Ie the reference line is vertical.

Cheers

 

uhhmmm :unsure: Yes?

 

|

|

|

\/

 

Replace 0 to 1.57079633

 

:D

Posted
That would be my guess, since the OP's location is Austria.

 

It works!

 

Thank you!

 

Best regards Martin

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