Jump to content

project chainage of polyline on a straight line


motee-z

Recommended Posts

  • Replies 30
  • Created
  • Last Reply

Top Posters In This Topic

  • pBe

    11

  • ReMark

    7

  • motee-z

    7

  • alanjt

    3

Top Posters In This Topic

Posted Images

Here's what i got so far:

 

 
(defun c:test (/ o str_prt blg result Dist_list)
 (while (not (setq o (car (entsel)))))
 (if (setq blg (cdr (assoc 90 (entget o))))
   (progn
     (repeat (- blg 1)
(setq result (cons
        (vlax-curve-getDistAtParam o
  (setq blg (1- blg)))
        result))
        )
     (setq fv (car result))
       (mapcar '(lambda (m)
     (setq Dist_list (cons (abs (- fv m)) Dist_list))
     (setq fv m))(cdr result))
     (setq result (cons (car result) (reverse Dist_list)))
       
     (if (> (car (vlax-curve-getStartPoint o))
     (car (vlax-curve-getEndPoint o))
  )
(setq result (reverse result))
     )
     (print result)
   )     ;progn
   (princ "\nNot a Polyline: ")
 )
 (princ)
)

 

So far all the code can do is get the length of every segment. and save it on a list, check the start point and test for direction. if its right to left itt will revesrse the length list. no sub for adding the polyline yet.

 

Problem i had with this method are:

1. How can i determine if the segment is a curve?

2. How do you guys determine the text height for labelling when creating text/attributes, i was planning to incorporate that with the code. but i always end up with the same question in my head, what will be the height of the text?

3. Is there a way using vanilla to get the length of the curve? at first i tried to do it with DXF. and using mathematical formula to compute the length of the curve but its taking too much time.

 

Anyway.. I'm still working on improving and making it "efficient" .. i'll post the update soon (or never :))

Link to comment
Share on other sites

I add this routin to plot chainage of segement of the polyline i need now the list of radius and the list of length of radius and central angles the routin of mr pBe help me too much thank you:

(defun testch (/ o str_prt blg Dist_list);

(vl-load-com)

(while (not (setq o (car (entsel)))))

(if (setq blg (cdr (assoc 90 (entget o))))

(progn

(repeat (- blg 1)

(setq result (cons

(vlax-curve-getDistAtParam o

(setq blg (1- blg)))

result))

)

(setq fv (car result))

(mapcar '(lambda (m)

(setq Dist_list (cons (abs (- fv m)) Dist_list))

(setq fv m))(cdr result))

(setq result (cons (car result) (reverse Dist_list)))

 

(if (> (car (vlax-curve-getStartPoint o))

(car (vlax-curve-getEndPoint o))

)

(setq result (reverse result))

)

(print result)

) ;progn

(princ "\nNot a Polyline: ")

)

(princ)

)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun c:plch(/ result)

(vl-load-com)

(testch)

(setq startp-chain (getreal "\n chainage of start point"))

(setq pt1 (getpoint "\n click plot point "))

(setq txth(getreal "\n enter text hieght"))

(setq nx (length result))

(setq chainage (list startp-chain))

(setq counter 0)

(while

(

(progn

(setq chainage(append chainage(list(+(nth counter chainage)(nth counter result)))))

(setq counter(+ counter 1))

)

)

(setq leall(-(nth nx chainage)(nth 0 chainage)))

(command "line" (list(car pt1)(cadr pt1))(list(+(car pt1)leall)(cadr pt1))"")

 

;(setq starp-chain(list startp-chain))

(setq result2(cons startp-chain(list result)))

(setq result3(list(cadr result2)))

(setq result4(nth 0 result3))

(setq nx2(length result4))

(command"line"(list(car pt1)(cadr pt1))(list(car pt1)(-(cadr pt1)(* txth 6)))"")

(command"text"(list(car pt1)(-(cadr pt1)(* txth 6))) txth 0 (rtos startp-chain 2 3))

(setq count2 0)

(while

(

 

(progn

(setvar "osmode"0)

(command"line"(list(+(car pt1)(nth count2 result4))(cadr pt1)) (list(+(car pt1)(nth count2 result4))(-(cadr pt1)(* txth 6)))"")

(command"text"(list(+(car pt1)(nth count2 result4))(-(cadr pt1)(* txth 6)))txth 0(rtos(nth(+ 1 count2) chainage)2 3))

(setq pt1(list(+(car pt1)(nth count2 result4))(cadr pt1)))

 

(setq count2(+ 1 count2))

)

)

)

Link to comment
Share on other sites

Your welcome :)

Good work motee-z.

 

Now if your heading down the path of prompting for user input, you might consider using default for the next run

something like this.

 

 
(if not sp
  (setq sp 1.00))
  (initget 2)
  (setq startp-chain (getreal (strcat "\n chainage of start point <" (rtos sp 2 2) ">: ")))
   (if  (not startp-chain)(setq startp-chain sp)(setq sp startp-chain)
    )

 

 

Not quite sure what you mean by this though

 

.... list of radius and the list of length of radius and central angles ....

Link to comment
Share on other sites

thank you mr pBe

for your help shall i wait for what i ask for

 

Instead of giving you fish, we will teach you how to fish

 

use vla-getbulge [GetBulge Method]

 

The bulge is the tangent of 1/4 of the included angle for the arc between the selected vertex and the next vertex in the polyline's vertex list.

A negative bulge value indicates that the arc goes clockwise from the selected vertex to the next vertex.

A bulge of 0 indicates a straight segment,

and a bulge of 1 is a semicircle.

 

:)

Link to comment
Share on other sites

actualy i don,t know how to use vla getbulge method

thanks

 

oh.. too bad.. anyway... i will modify your code as soon as i have the time...

having a busy week... :sweat:

Link to comment
Share on other sites

  • 11 years later...
On 12/3/2010 at 11:23 PM, motee-z said:

I add this routin to plot chainage of segement of the polyline i need now the list of radius and the list of length of radius and central angles the routin of mr pBe help me too much thank you:

(defun testch (/ o str_prt blg Dist_list);

(vl-load-com)

(while (not (setq o (car (entsel)))))

(if (setq blg (cdr (assoc 90 (entget o))))

(progn

(repeat (- blg 1)

(setq result (cons

(vlax-curve-getDistAtParam o

(setq blg (1- blg)))

result))

)

(setq fv (car result))

(mapcar '(lambda (m)

(setq Dist_list (cons (abs (- fv m)) Dist_list))

(setq fv m))(cdr result))

(setq result (cons (car result) (reverse Dist_list)))

 

(if (> (car (vlax-curve-getStartPoint o))

(car (vlax-curve-getEndPoint o))

)

(setq result (reverse result))

)

(print result)

) ;progn

(princ "\nNot a Polyline: ")

)

(princ)

)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun c:plch(/ result)

(vl-load-com)

(testch)

(setq startp-chain (getreal "\n chainage of start point"))

(setq pt1 (getpoint "\n click plot point "))

(setq txth(getreal "\n enter text hieght"))

(setq nx (length result))

(setq chainage (list startp-chain))

(setq counter 0)

(while

(

(progn

(setq chainage(append chainage(list(+(nth counter chainage)(nth counter result)))))

(setq counter(+ counter 1))

)

)

(setq leall(-(nth nx chainage)(nth 0 chainage)))

(command "line" (list(car pt1)(cadr pt1))(list(+(car pt1)leall)(cadr pt1))"")

 

;(setq starp-chain(list startp-chain))

(setq result2(cons startp-chain(list result)))

(setq result3(list(cadr result2)))

(setq result4(nth 0 result3))

(setq nx2(length result4))

(command"line"(list(car pt1)(cadr pt1))(list(car pt1)(-(cadr pt1)(* txth 6)))"")

(command"text"(list(car pt1)(-(cadr pt1)(* txth 6))) txth 0 (rtos startp-chain 2 3))

(setq count2 0)

(while

(

 

(progn

(setvar "osmode"0)

(command"line"(list(+(car pt1)(nth count2 result4))(cadr pt1)) (list(+(car pt1)(nth count2 result4))(-(cadr pt1)(* txth 6)))"")

(command"text"(list(+(car pt1)(nth count2 result4))(-(cadr pt1)(* txth 6)))txth 0(rtos(nth(+ 1 count2) chainage)2 3))

(setq pt1(list(+(car pt1)(nth count2 result4))(cadr pt1)))

 

(setq count2(+ 1 count2))

)

)

)

 Something wrong with code

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