Jump to content

Measure a polyline with a block and stop after inserting first block.


Recommended Posts

Posted

I want to insert a block at a given distance from a start end of a polyline.

Pl. can somebody give me a code.

Posted (edited)

Need a little more information or a sample drawing.

Must have just read title

 

Assumes start end of poly are same distance.  Easy enough using vlax-curve-getpointatdist. error check to see if distance is less than 1/2 the distance of the polyline. or the start block would be past the end block on the polyline.

;;----------------------------------------------------------------------------;;
;; INSERT BLOCK AT DISTANCE FROM ENDPOINTS ON POLYLINE
(defun C:foo (/ dist poly Spt Ept)
  (vl-load-com)
  (setvar 'cmdecho 0)
  (setq dist (getdist "\nDistance from ends of poyline: "))
  (setq poly (vlax-ename->vla-object (car (entsel "\nSelect Polyline: "))))
  (if (< dist (/ (vla-get-length poly) 2))
    (progn
      (setq Spt (vlax-curve-getpointatdist poly dist))
      (command "_.Insert" blockname "_non" Spt "" "" "")
      (setq Ept (vlax-curve-getpointatdist poly (- (vla-get-length poly) dist)))
      (command "_.Insert" blockname "_non" Ept "" "" "")
    )
    (prompt "\nDistance is to large")
  )
  (setvar 'cmdecho 1)
  (princ)
)

 

Edited by mhupp
cmdecho and princ
  • Like 1
Posted

Along the polyline? Look at chainage LISPS, there are some that will place a block there and I think will have a repeat or while loop as it iterates along the line, maybe all you need is to take that out to get the first distance.

  • Agree 1

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