Bane Posted May 6, 2008 Share Posted May 6, 2008 New problem for me: I had LINES and ARCS those I joined to single polyline. I want to create points along the polyline at strictly defined distances from the first polyline vertex. It's all about 2D. Any idea will be fine for me. Thanks. Quote Link to comment Share on other sites More sharing options...
PS_Port Posted May 6, 2008 Share Posted May 6, 2008 Block out a point/node you require eg. call it `Point1' command MEASURE, select `pline' , specify BLOCK "Point1", then DISTANCE apart. Lisp should be easy to write, but I'm not sure if it will speed up the above process much.. Quote Link to comment Share on other sites More sharing options...
Bane Posted May 6, 2008 Author Share Posted May 6, 2008 Thank you, it works fine "manually". However, I need lisp code, because there is more things that I have to do after creating these points. This polyline is horizontal alignment actually. Profile lines (perpendicular to alignment) should be created through mentioned created points. The problem is how to create profile line if point is created somewhere on arc... How to define a center of arc which is a part of polyline? Any suggestions? Block out a point/node you require eg. call it `Point1' command MEASURE, select `pline' , specify BLOCK "Point1", then DISTANCE apart. Lisp should be easy to write, but I'm not sure if it will speed up the above process much.. Quote Link to comment Share on other sites More sharing options...
PS_Port Posted May 6, 2008 Share Posted May 6, 2008 I think I get what you are after, I see what I can come up with after lunch. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 6, 2008 Share Posted May 6, 2008 in a lisp If you pick point first then perp to polyline this draws a line Ok now want each line a certain length, as you have a line you can use last line to get angle of line then redraw it in both directions repeat as required Quote Link to comment Share on other sites More sharing options...
PS_Port Posted May 6, 2008 Share Posted May 6, 2008 Bane after looking at the problem, I still think MEASURE is the way to go. see pic. forgot to add this to the pic.- block created has a midpoint insertion point. here is the command line. Command: MEASURE Select object to measure: Specify length of segment or [block]: B Enter name of block to insert: PROFILE Align block with object? [Yes/No] : Y Specify length of segment: 500 Just realised you are a civil guy.. maybe someone in that field might have a better solution.. Quote Link to comment Share on other sites More sharing options...
Bane Posted May 6, 2008 Author Share Posted May 6, 2008 Well done, but my distances are not always the same. For example first profile line may be at 30.000m from from vertex, next 42.341m from first vertex... Yes I am a Civil man. Thank you for help. Bane after looking at the problem, I still think MEASURE is the way to go.see pic. forgot to add this to the pic.- block created has a midpoint insertion point. here is the command line. Just realised you are a civil guy.. maybe someone in that field might have a better solution.. Quote Link to comment Share on other sites More sharing options...
fixo Posted May 6, 2008 Share Posted May 6, 2008 I have not have a time to test it Give it a try, but comment unused part of code before included between ***, if you wan't to insert blocks as show on picture (defun C:test(/ ang cumm_dist dis dist_list leng obj pt) (vl-load-com) ;; build master list of the distances, starting from 0.0 - important! (setq dist_list '(0.0 1000.0 2000.0 3000.0 4000.0 5000.0)) (setq cumm_dist (apply '+ dist_list)) (setq dis 0.0) (setq obj (vlax-ename->vla-object (car (entsel "\n >> Select profile >>")))) (setq leng (vlax-curve-getdistatpoint obj (vlax-curve-getendpoint obj))) ;; check if pline length is not less than the cumulative distance (if (< leng cumm_dist) (progn (alert "Pline length is less then summary distance") (princ) ) (while (< dis cumm_dist) (setq dis (+ dis (car dist_list))) (setq pt (vlax-curve-getpointatdist obj dis)) ;;;*** ;;to insert block named "tick": ;; get angle: (setq ang (angle '(0 0 0) (vlax-curve-getfirstderiv obj (vlax-curve-getparamatpoint obj pt)))) ;;insert block: (vlax-invoke (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) 'InsertBlock pt "tick" 1 1 1 ang);*** ;;or draw point: (vlax-invoke (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) 'AddPoint pt) (setq dist_list (cdr dist_list)) ) ) (princ) ) ~'J'~ Quote Link to comment Share on other sites More sharing options...
Bane Posted May 6, 2008 Author Share Posted May 6, 2008 I don't know what to say... Thank you Fatty, great job. It works perfectly. I am not familiar with visual lisp, but I will try to continue to next step using basic lisp. Thank you very much!!! I have not have a time to test itGive it a try, but comment unused part of code before included between ***, if you wan't to insert blocks as show on picture (defun C:test(/ ang cumm_dist dis dist_list leng obj pt) (vl-load-com) ;; build master list of the distances, starting from 0.0 - important! (setq dist_list '(0.0 1000.0 2000.0 3000.0 4000.0 5000.0)) (setq cumm_dist (apply '+ dist_list)) (setq dis 0.0) (setq obj (vlax-ename->vla-object (car (entsel "\n >> Select profile >>")))) (setq leng (vlax-curve-getdistatpoint obj (vlax-curve-getendpoint obj))) ;; check if pline length is not less than the cumulative distance (if (< leng cumm_dist) (progn (alert "Pline length is less then summary distance") (princ) ) (while (< dis cumm_dist) (setq dis (+ dis (car dist_list))) (setq pt (vlax-curve-getpointatdist obj dis)) ;;;*** ;;to insert block named "tick": ;; get angle: (setq ang (angle '(0 0 0) (vlax-curve-getfirstderiv obj (vlax-curve-getparamatpoint obj pt)))) ;;insert block: (vlax-invoke (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) 'InsertBlock pt "tick" 1 1 1 ang);*** ;;or draw point: (vlax-invoke (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) 'AddPoint pt) (setq dist_list (cdr dist_list)) ) ) (princ) ) ~'J'~ Quote Link to comment Share on other sites More sharing options...
Bane Posted May 6, 2008 Author Share Posted May 6, 2008 Another one similar question: If I have the same polyline and create profile lines manually on certain positions along the polyline (as blocks or just lines), is there possibility to write the code which will find these lines' (or blocks) positions on the polyline and show their distances from first Vertex (in command prompt or write to file)? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 7, 2008 Share Posted May 7, 2008 1st are you running civil 3d ? if so read the help or seek advice from your dealer. 2nd The majority of civil programs have chainage labelling routines buit in as standard their level of ability varies (civil 3D is not the best at this about to load 2009 maybe better) from ch at equal spacing plus Tp's to the ability to pick random points from the drawing and add in or just type in a chainage in a table add ch's at different spacing lots of stuff we use ARD+civil 3D. 3rd if you dont have civil 3d there are some good civil add ons available at moderate prices that do surfaces, long & cross sections volumes etc. Just search the net. 4th writing lots of routines will take a long time and possible time cost v's purchase would be better. Quote Link to comment Share on other sites More sharing options...
fixo Posted May 7, 2008 Share Posted May 7, 2008 Another one similar question: If I have the same polyline and create profile lines manually on certain positions along the polyline (as blocks or just lines), is there possibility to write the code which will find these lines' (or blocks) positions on the polyline and show their distances from first Vertex (in command prompt or write to file)? This will works if your profile was measured with lines as on the picture above Profile must be as LWPOLYLINE only, otherwise I need to rewrite this lisp code The text file will be saved in the same folder you work in or select other folder you need in the file dialog Accordingly that to do the same with blocks - I have not have a time at the moment, perhaps, later I could be able to write something to solve it ;;============================wl.lsp=============================;; ;; local defun (defun parse-dist (lst / ret) (setq ret (mapcar '- (cdr lst) (reverse (cdr (reverse lst))))) (if (zerop (car lst)) (setq ret (append (list 0.0) ret)) ) ret ) ;; main part (defun C:WL (/ axss dist_list dp fn fss obj p1 p2 pc ptlist pts sep_list ss txt_file_name txt_list) (vl-load-com) (prompt "\n >> Select the profile >>") (if (setq ss (ssget "_+.:S:E" (list (cons 0 "LWPOLYLINE")))) (progn (setq obj (vlax-ename->vla-object (ssname ss 0))) (setq pts (vlax-get obj 'Coordinates)) (while (cadr pts) (setq ptlist (cons (trans (list (car pts)(cadr pts)) 1 0) ptlist)) (setq pts (cddr pts)) ) (setq fss (ssget "F" ptlist (list (cons 0 "LINE")))) (setq axss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))) (vlax-for a axss (setq p1 (vlax-curve-getstartpoint a) p2 (vlax-curve-getendpoint a) pc (mapcar (function(lambda(a b)(* (+ a b) 0.5))) p1 p2);mid point of line dp (vlax-curve-getclosestpointto obj pc) dist_list (cons (vlax-curve-getdistatpoint obj dp) dist_list) ) ) (setq sep_list (parse-dist dist_list)) (setq txt_list (mapcar 'vl-princ-to-string sep_list)) (setq txt_file_name (getfiled "Enter file name without extension" (getvar "dwgprefix") "txt" 1)) (setq fn (open txt_file_name "w")) (setq cnt 1) (mapcar (function (lambda (x) (write-line (strcat (itoa cnt) "," x) fn) (setq cnt (1+ cnt))) ) txt_list) (close fn) ) ) (princ) ) ;;============================wl.lsp=============================;; Quote Link to comment Share on other sites More sharing options...
Bane Posted May 7, 2008 Author Share Posted May 7, 2008 Well, I know what you talking about. I have Civil 3D on my workplace and I am familiar with it. However, this is a great place with great unselfish people who want to learn something new or teach other people in programming. I am interesting in Lisp, Visual Lisp, VBA... 1st are you running civil 3d ? if so read the help or seek advice from your dealer. 2nd The majority of civil programs have chainage labelling routines buit in as standard their level of ability varies (civil 3D is not the best at this about to load 2009 maybe better) from ch at equal spacing plus Tp's to the ability to pick random points from the drawing and add in or just type in a chainage in a table add ch's at different spacing lots of stuff we use ARD+civil 3D. 3rd if you dont have civil 3d there are some good civil add ons available at moderate prices that do surfaces, long & cross sections volumes etc. Just search the net. 4th writing lots of routines will take a long time and possible time cost v's purchase would be better. Quote Link to comment Share on other sites More sharing options...
Bane Posted May 7, 2008 Author Share Posted May 7, 2008 That's what I want. Really good job. Thank you Fatty. This will works if your profile was measuredwith lines as on the picture above Profile must be as LWPOLYLINE only, otherwise I need to rewrite this lisp code The text file will be saved in the same folder you work in or select other folder you need in the file dialog Accordingly that to do the same with blocks - I have not have a time at the moment, perhaps, later I could be able to write something to solve it ;;============================wl.lsp=============================;; ;; local defun (defun parse-dist (lst / ret) (setq ret (mapcar '- (cdr lst) (reverse (cdr (reverse lst))))) (if (zerop (car lst)) (setq ret (append (list 0.0) ret)) ) ret ) ;; main part (defun C:WL (/ axss dist_list dp fn fss obj p1 p2 pc ptlist pts sep_list ss txt_file_name txt_list) (vl-load-com) (prompt "\n >> Select the profile >>") (if (setq ss (ssget "_+.:S:E" (list (cons 0 "LWPOLYLINE")))) (progn (setq obj (vlax-ename->vla-object (ssname ss 0))) (setq pts (vlax-get obj 'Coordinates)) (while (cadr pts) (setq ptlist (cons (trans (list (car pts)(cadr pts)) 1 0) ptlist)) (setq pts (cddr pts)) ) (setq fss (ssget "F" ptlist (list (cons 0 "LINE")))) (setq axss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))) (vlax-for a axss (setq p1 (vlax-curve-getstartpoint a) p2 (vlax-curve-getendpoint a) pc (mapcar (function(lambda(a b)(* (+ a b) 0.5))) p1 p2);mid point of line dp (vlax-curve-getclosestpointto obj pc) dist_list (cons (vlax-curve-getdistatpoint obj dp) dist_list) ) ) (setq sep_list (parse-dist dist_list)) (setq txt_list (mapcar 'vl-princ-to-string sep_list)) (setq txt_file_name (getfiled "Enter file name without extension" (getvar "dwgprefix") "txt" 1)) (setq fn (open txt_file_name "w")) (setq cnt 1) (mapcar (function (lambda (x) (write-line (strcat (itoa cnt) "," x) fn) (setq cnt (1+ cnt))) ) txt_list) (close fn) ) ) (princ) ) ;;============================wl.lsp=============================;; Quote Link to comment Share on other sites More sharing options...
fixo Posted May 7, 2008 Share Posted May 7, 2008 Glad if that what you want Happy computing ~'J'~ Quote Link to comment Share on other sites More sharing options...
George Duls Posted May 12, 2008 Share Posted May 12, 2008 Hello, just one quick question please. I have the same issue as bane. One big polyline (the axis) and profiles. And if I want to get the distance of the axis at the profile, then I have to put the profile line on the axis (at the mid-point of the profile line), calculate the mid-point from /start&end point/ and use vlax-curve-getdistatpoint. Is there any simple way to do this (so I don't have to put all the profiles in their midpoint)? ThankYou&greetings! Quote Link to comment Share on other sites More sharing options...
fixo Posted May 12, 2008 Share Posted May 12, 2008 George, there is not clearly enough for my dim brain Please, attach the sample drawing or screenshot of what you want ~'J'~ Quote Link to comment Share on other sites More sharing options...
priyanka_mehta Posted June 18, 2009 Share Posted June 18, 2009 Hi, Is there a way of doing this using VBA?? Regards, Priyanka Quote Link to comment Share on other sites More sharing options...
josecosta Posted November 18, 2014 Share Posted November 18, 2014 I don't know what to say... Thank you Fatty, great job. It works perfectly.I am not familiar with visual lisp, but I will try to continue to next step using basic lisp. Thank you very much!!! Hi! Is there a way to make the routine works with 3D Poly? I need a polyline that matchs with my terrain. Thank you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.