Jump to content

measure polyline with increment block


sanju2323

Recommended Posts

Hi,

 

Can you explain your goal in a bit more details ? it does not seem clear enough to me to get what you want from the attached drawing.

 

You should have asked Tharwat direct via here. He is very helpful.

Thank you BIGAL , it is very kind of you to say that. highly appreciated.

Link to comment
Share on other sites

Sir, I have to measure Polyline at 1750 meters, and also put the chainage in the block. But I wanted serial No. instead of chainage.

Thank you

Link to comment
Share on other sites

Try this.

 

(defun c:Test (/ b s e l d g n a p)
 ;; Tharwat 13.Feb.2016 ;;
 (setq b "MATCH_LINE");; Block name
 (if
   (and (if (tblsearch "BLOCK" b)
          t
          (progn
            (alert
              (strcat "Block name <" b "> is not found in drawing !")
            )
            nil
          )
        )
        (princ "\nSelect LWpolyline :")
        (setq s (ssget "_+.:S:E" '((0 . "LWPOLYLINE"))))
        (setq l (vlax-curve-getdistatpoint
                  (setq e (ssname s 0))
                  (vlax-curve-getendpoint e)
                )
              d 1750.
              g d
              n 1
              p (vlax-get (vla-get-activelayout
                            (vla-get-ActiveDocument (vlax-get-acad-object))
                          )
                          'Block
                )
        )
   )
    (repeat (fix (/ l 1750))
      (if (setq a (vla-InsertBlock
                    p
                    (vlax-3d-point (vlax-curve-getpointatdist e d))
                    b
                    1.0
                    1.0
                    1.0
                    0.
                  )
          )
        (progn
          (vla-put-rotation
            a
            (angle '(0. 0. 0.)
                   (vlax-curve-getfirstderiv
                     e
                     (vlax-curve-getparamatpoint
                       e
                       (vlax-curve-getpointatdist e d)
                     )
                   )
            )
          )
          (vla-put-textstring
            (car (vlax-invoke a 'getattributes))
            (strcat "GAIL-MSA-CHOKARI TO UNDERA-AS-"
                    (cond ((< n 10) "00")
                          ((< n 100) "0")
                          (t "")
                    )
                    (itoa n)
            )
          )
          (setq n (1+ n)
                d (+ d g)
          )
        )
      )
    )
 )
 (princ)
)
(vl-load-com)

Link to comment
Share on other sites

Tharwat,

Thanks for your lisp code, it's great. Please you can add the option to polyline manually measure the distance.

 

Excellent, try this [uNTESTED] adds.

 

(defun c:Test (/ b s e l d g n a p j)
 ;; Tharwat 13.Feb.2016 ;;
 (setq b "MATCH_LINE");; Block name
 (if
   (and (if (tblsearch "BLOCK" b)
          t
          (progn
            (alert
              (strcat "Block name <" b "> is not found in drawing !")
            )
            nil
          )
        )
        (princ "\nSelect LWpolyline :")
        (setq s (ssget "_+.:S:E" '((0 . "LWPOLYLINE"))))
        (setq j (getdist "\nSpecify Distance on LWpolyline to place blocks :"))
        (setq l (vlax-curve-getdistatpoint
                  (setq e (ssname s 0))
                  (vlax-curve-getendpoint e)
                )
              d j
              g d
              n 1
              p (vlax-get (vla-get-activelayout
                            (vla-get-ActiveDocument (vlax-get-acad-object))
                          )
                          'Block
                )
        )
        (if (> l j)
          t
          (progn
            (princ (strcat "\nInserted Distance <" (rtos j 2 4) "> is shorter than selected LWpolyline's length !")) nil))
   )
    (repeat (fix (/ l j))
      (if (setq a (vla-InsertBlock  p (vlax-3d-point (vlax-curve-getpointatdist e d))
                    b
                    1.0
                    1.0
                    1.0
                    0.
                  )
          )
        (progn
          (vla-put-rotation a (angle '(0. 0. 0.) (vlax-curve-getfirstderiv e (vlax-curve-getparamatpoint
                       e (vlax-curve-getpointatdist e d) ) ) )
          )
          (vla-put-textstring (car (vlax-invoke a 'getattributes)) (strcat "GAIL-MSA-CHOKARI TO UNDERA-AS-"
                    (cond ((< n 10) "00")
                          ((< n 100) "0")
                          (t "")
                    )
                    (itoa n)
            )
          )
          (setq n (1+ n)
                d (+ d g)
          )
        )
      )
    )
 )
 (princ)
)(vl-load-com)

Link to comment
Share on other sites

Hi Tharwat, You can add one more option. "GAIL-MSA-CHOKARI TO UNDERA-AS-" is the name of the drawing, so please add it manually option of asking.

Edited by sanju2323
Link to comment
Share on other sites

  • 2 years later...

Hi Tharwat, I want to use your lisp and I get the following error "; error: no function definition: VLAX-CURVE-GETENDPOINT".

Can you please help.

 

Thank you!

Link to comment
Share on other sites

1 hour ago, Cristian C. said:

Hi Tharwat, I want to use your lisp and I get the following error "; error: no function definition: VLAX-CURVE-GETENDPOINT".

Can you please help.

 

Thank you!

Hi,

It seems that your AutoCAD does not load the vl-functions library or it may not loaded with your version, so if you repair your CAD version from Control Panel that should help otherwise you may need to reinstall your version once again.

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