Author Topic: Help me to convert a file  (Read 11152 times)

0 Members and 1 Guest are viewing this topic.

pedroantonio

  • Guest
Help me to convert a file
« on: December 12, 2015, 10:58:18 AM »
I have a drawing with 125 cross section (i upload one of them).
I have a drawing of a road .I want to steak out this road so i want to export the position and elevetion from the cross sections.I have export for the cross section the distansce and the elevetion to a *.txt file.I need a lisp to convert me this files to (point number,x,y,elevetion) files

Read the test.dwg and  will understand

Thanks
« Last Edit: December 12, 2015, 02:14:21 PM by Topographer »

pedroantonio

  • Guest
Re: Help me to convert a file
« Reply #1 on: December 12, 2015, 02:14:52 PM »
Any ideas ?

Thanks
« Last Edit: December 12, 2015, 02:27:59 PM by Topographer »

ymg

  • Guest
Re: Help me to convert a file
« Reply #2 on: December 12, 2015, 02:58:34 PM »
topographer,

Do you have the alignment of the center line and the chainage
of each section ?

Right now your data file does not give the chainage.

(vlax-curve-getpointatdist alignment chainage) will give you a point
(vlax-curve-getfirstderivative ....  will give you the direction of the alignment

Then simply calculate each point at 90 degree from this angle.

ymg


pedroantonio

  • Guest
Re: Help me to convert a file
« Reply #3 on: December 12, 2015, 03:15:11 PM »
Hi ymg.Look If you know for example the coordinates ,the distanse and the angle you can calculate the coordinates of a new point.I have in a file the distanse and the elevetion of the new point but i dont have the angle so. I need a lisp to select the aligment of the cross section ,grab the cordinate of the midle point of the cross section ,and convert the length , elevetion txt file to (point,x,y,elev) (with point name 1,2,3 .... i don't  care  what).

I dont need the chainge i can do it this manualy for eatch section. For the time is very big help to convert the file

Thanks

pedroantonio

  • Guest
Re: Help me to convert a file
« Reply #4 on: December 12, 2015, 03:18:47 PM »
Code: [Select]
Then simply calculate each point at 90 degree from this angle.
I use grads ,and direction north for the most of my drawings.

ymg

  • Guest
Re: Help me to convert a file
« Reply #5 on: December 12, 2015, 05:29:49 PM »
topographer,

First select your alignment and assign it's ename to variable en:
Code - Auto/Visual Lisp: [Select]
  1. (setq en (car (entsel "\nSelect Alignment: ")))
  2.  


You kow how to get the point knowing the chainage as a real number:

Code - Auto/Visual Lisp: [Select]

The reference angle you can get with this function:
Code - Auto/Visual Lisp: [Select]
  1. ;;                                                                            ;
  2. ;; Return angle along curve, at specified point (on curve)                    ;
  3. ;; e - valid curve (ENAME or VLA-OBJECT)                                      ;
  4. ;; p - point on curve                                                         ;
  5. ;; Alan J. Thompson, 11.04.10                                                 ;
  6. ;;                                                                            ;
  7.  
  8. (defun AngleAtPoint (e p)
  9. )
  10.  


Then your section point will all be at:
Code - Auto/Visual Lisp: [Select]
  1. (polar point (+ refangle (/ pi 2)) sdist)
  2.  

Replace the z of the point calculated above by the one in your cross section.

Now stop asking question and get coding!

ymg

pedroantonio

  • Guest
Re: Help me to convert a file
« Reply #6 on: December 13, 2015, 02:30:21 AM »
Thanks you ymg for the help but the problem is that I am not good in lisp. To coding this lisp if very difficult for my level  :oops:

pedroantonio

  • Guest
Re: Help me to convert a file
« Reply #7 on: December 14, 2015, 02:28:39 AM »
Hi ymg.Can you help me more  :embarrassed:

Thanks

pedroantonio

  • Guest
Re: Help me to convert a file
« Reply #8 on: December 15, 2015, 11:48:35 AM »
with the help of ymg this is the idea. I dont know how to continue. Can any one finish this code.I am not good in lisp . I have a lot of work to do and this code will help me a lot.

Code - Auto/Visual Lisp: [Select]
  1. (setq en (car (entsel "\nSelect Alignment: ")))
  2.  
  3.  
  4. ;; Read the file with the distanse and elevetion
  5.  
  6. (SETQ F1 (OPEN FNAME "r"))
  7.  
  8.  
  9. ;;                                                                            ;
  10. ;; Return angle along curve, at specified point (on curve)                    ;
  11. ;; e - valid curve (ENAME or VLA-OBJECT)                                      ;
  12. ;; p - point on curve                                                         ;
  13. ;; Alan J. Thompson, 11.04.10                                                 ;
  14. ;;                                                                            ;
  15.  
  16. (defun AngleAtPoint (e p)
  17. )
  18.  
  19.  
  20. (polar point (+ refangle (/ pi 2)) sdist)
  21.  
  22. ;; Save the new file p,x,y,z
  23.  
  24. (setq fn (getfiled "save file as  P,x,y,z" "" "txt" 1))
  25.  

Thanks

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Help me to convert a file
« Reply #9 on: December 15, 2015, 11:58:17 AM »
with the help of ymg this is the idea. I dont know how to continue. Can any one finish this code.I am not good in lisp . I have a lot of work to do and this code will help me a lot.

Code - Auto/Visual Lisp: [Select]
  1. (setq en (car (entsel "\nSelect Alignment: ")))
  2.  
  3.  
  4. ;; Read the file with the distanse and elevetion
  5.  
  6. (SETQ F1 (OPEN FNAME "r"))
  7.  
  8.  
  9. ;;                                                                            ;
  10. ;; Return angle along curve, at specified point (on curve)                    ;
  11. ;; e - valid curve (ENAME or VLA-OBJECT)                                      ;
  12. ;; p - point on curve                                                         ;
  13. ;; Alan J. Thompson, 11.04.10                                                 ;
  14. ;;                                                                            ;
  15.  
  16. (defun AngleAtPoint (e p)
  17. )
  18.  
  19.  
  20. (polar point (+ refangle (/ pi 2)) sdist)
  21.  
  22. ;; Save the new file p,x,y,z
  23.  
  24. (setq fn (getfiled "save file as  P,x,y,z" "" "txt" 1))
  25.  

Thanks
You really have to start trying to write your own code.  ;)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pedroantonio

  • Guest
Re: Help me to convert a file
« Reply #10 on: December 15, 2015, 12:09:45 PM »
Always ronjonp your comments are negative. Can you  help me one time  without doing me an observation? We're not  all good in programming as you !!!!  :-)

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Help me to convert a file
« Reply #11 on: December 15, 2015, 12:16:23 PM »
Always ronjonp your comments are negative. Can you  help me one time  without doing me an observation? We're not  all good in programming as you !!!!  :)
Negative.
« Last Edit: December 15, 2015, 12:21:21 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pedroantonio

  • Guest
Re: Help me to convert a file
« Reply #12 on: December 15, 2015, 03:08:48 PM »
I need help to finish the code.
I have in a file the distanse and the elevetion of the new point but i dont have the angle so.
I need a lisp to select the aligment of the cross section ,grab the coordinate of the midle point of the cross section ,and convert the length , elevetion txt file to (point,x,y,elev) (with point name 1,2,3 .... i don't  care  what).

Thanks
« Last Edit: December 15, 2015, 03:13:42 PM by Topographer »

ymg

  • Guest
Re: Help me to convert a file
« Reply #13 on: December 15, 2015, 09:14:45 PM »
topographer,

You should not see Ronjomp's commentaries as negative, actually every links
he gave you is helpful in achieving your goal.

We are trying to shock you into jumping in and actually doing the effort
required to code your own.

This is not out of contempt, but actually trying to help you achieve something
that would/will be a tremendous plus in your career.

Although, you did a little effort in the previous post you need to do a little more
if you want us to help you.

For example, there is nothing telling us how your data is organized.  Are all the files
for a given alignment in a single folder.  If so we need to iterate all xsection files of
the folder and create a single point file out of it.

You posted an image about the angle being an unknown.  I explained to you
in previous post that all you need is the first derivative of the center line point
at the chainage of the section. This is the tangent to the curve.

Function "angleatpoint" gives you the direction of that tangent.  So to make
a long story short your angle is always 90 degrees, which correspond to an
angle of pi/2 radian.

So (polar p (+ (angleatpoint p en)  (/ pi 2)) dist) always gives you the points
on your section. (Notes that your distance are kept negative on left side of alignment)

Other question how are your file named ?

Can we extract the chainage from the file name ?

We understand that you are busy. But a little effort now will repay itself
a thousand times.

ymg

pedroantonio

  • Guest
Re: Help me to convert a file
« Reply #14 on: December 16, 2015, 01:35:51 AM »
Good morning ymg.I will try to explain from the beginning what i want.
I have 125 cross section to steak out and a road design.
I export the data from eatch cross section to a txt file .This data is (lengths and elevetion) .The lengths with (-) are from the left and the other lengths  are from the right. (look the txt file)
In the road drawing for eatch section you can see a green line vertical to the road center line.
I want this lisp to work for one cross section per time (I dont want to add the  chainage ) .

The lisp i want to work like this:

1) pick the middle of green cross section line from the road drawing anf grab the coordinates
2)Select the green cross section line from the road drawing (and canlulate the angle G look the test.dwg)
3)open window and select the cross section file with the lengths and elevetions
4)Tranform this this file to a new file p,x,y,elev

So i can have the the cross section data over the road design.


Thanks
« Last Edit: December 16, 2015, 01:42:07 AM by Topographer »