Jump to content

Measure block along polyline with specify lengths


sivapathasunderam

Recommended Posts

Hello;

 

I need a Lisp that will measure blocks along polyline by specify length

(The length should always calculate from 0, beginning of polyline)

 

Eample:

Drawing unit is in Meter

I have a Road center line of 10Km (10000m), if i enter length 3300m block should place at 3300m

if i enter length 5600m block should place at 5600m

 

Many thanks

Siva

cadtutor123.jpg

Link to comment
Share on other sites

Hi;

 

Block name is CATCH_PIT with one attribute as shown

Rotation is Perpendicular to alignment of the Road, as i attached dwg

 

catchpit location.jpg

 

cannot able to attach file size is more than 1MB

 

thanks

Siva

cadtutor45.jpg

Edited by sivapathasunderam
added clear image
Link to comment
Share on other sites

Try this draft and let me know.

 


(defun c:Test  (/ blk s e l d v)
 ;; Tharwat 07.Feb.2016 ;;
 (setq blk "CATCH_PIT")
 ;; Block name
 (if (and (tblsearch "BLOCK" blk)
          (princ "\nSelect LWpolyline :")
          (setq s (ssget "_+.:S:E" '((0 . "LWPOLYLINE"))))
          (setq l (vlax-curve-getdistatpoint
                    (setq e (ssname s 0))
                    (vlax-curve-getendpoint e))))
   (while
     (and
       (setq d
              (getdist
                (strcat "\nSpecify distance less than "
                        (rtos l 2 2)
                        " > :")
                )
             )
       (< d l)
       (/= "" (setq v (getstring t "\nSpecify Attribute Value :")))
       )
      (entmake
        (list '(0 . "INSERT")
              (cons 10 (vlax-curve-getpointatdist e d))
              (cons 50
                    (+ (* pi 0.5)(angle '(0. 0. 0.)
                           (vlax-curve-getfirstderiv
                             e
                             (vlax-curve-getparamatpoint
                               e
                               (vlax-curve-getpointatdist e d))))))                     
              (cons 2 blk)
              )
        )
      (if (> d l)
        (alert "\nLong distance entered !")
        )
      )
   )
 (princ)
 )(vl-load-com)

Edited by Tharwat
Link to comment
Share on other sites

Codes updated above , try again.

 

Excellent work Tharwat!

I really appreciate it.

 

I search the google for more than 5 hours couldn't get any thing

 

Thanks for the help!

Siva

Link to comment
Share on other sites

Excellent work Tharwat!

I really appreciate it.

 

I search the google for more than 5 hours couldn't get any thing

 

Thanks for the help!

Siva

 

Nice. Happy to hear that - you are most welcome Siva.

Link to comment
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
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...