how to create lisp to make a profile from text file in autocad

how to create lisp to make a profile from text file in autocad

giscivil92
Advocate Advocate
2,280 Views
12 Replies
Message 1 of 13

how to create lisp to make a profile from text file in autocad

giscivil92
Advocate
Advocate

Hello everyone

I have some information like this format Kilometer  Elevation as a text file!

giscivil92_0-1711355334717.png

I appreciate it if you guide me, how can I create a lisp to create a profile from a file like the above format in AutoCAD!?

Thanks for your attention

 

0 Likes
2,281 Views
12 Replies
Replies (12)
Message 2 of 13

hak_vz
Advisor
Advisor

Simplest way

Rewrite your profile data as let say

0,100

20,80

30,90....

Place UCS origin to start from 0,0 of profile you are creating

copy all data to clipboard

start command PLINE and paste

finish PLINE command with enter

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 13

-didier-
Advisor
Advisor

Bonjour @giscivil92 

 

To do what you’re asking, you’d have to give us examples.
I understand that we start from a TXT file, but what should we get as a drawing?
Thank you for helping us to help you.

 

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

0 Likes
Message 4 of 13

giscivil92
Advocate
Advocate

@-didier- 

@hak_vz 

Hi 

A vertical profile with grids like this, 

read the information from text file and create grid.

giscivil92_0-1711362447917.png

 

0 Likes
Message 5 of 13

hak_vz
Advisor
Advisor

@giscivil92 wrote:

@-didier- 

@hak_vz 

Hi 

A vertical profile with grids like this, 

read the information from text file and create grid.

 


Sorry have no time to work on your lisp, currently at work. This lisp  is so simple but you didn't start with lisp programing.

Anyway, Align UCS along vertical axis (command UCS OB) and paste points in pline command. It takes exactly same time as open the lisp and pick starting point.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 6 of 13

kajanthangavel
Advocate
Advocate

Hi, I did the same work at my previous company. I think this is help you.

(defun LWPoly ( lst )
  (entmakex
    (append
      (list
        (cons 0 "LWPOLYLINE")
        (cons 100 "AcDbEntity")
        (cons 100 "AcDbPolyline")
        (cons 90 (length lst))
      )
      (mapcar '(lambda ( p ) (cons 10 (trans p 1 0))) lst)
    )
  )
)
(defun c:pro (/ pline ht ch)
(command "ucs" (getpoint "\nPick starting point :") "")
	(while
		(and
			(setq ch (getreal "\nType or paste Station : "))
			(setq ht (getreal "\nType or paste Hight : "))
		)
	(setq pline (cons (list ht (- 0 ch)) pline))
	)
(LWPoly pline)
(command "ucs" "p" )
(princ)
)

 

Profile (PRO).gif

0 Likes
Message 7 of 13

giscivil92
Advocate
Advocate

@kajanthangavel Hi

Thanks for your attention, That's it but I want to draw those grids and labels along with polyline!

0 Likes
Message 8 of 13

-didier-
Advisor
Advisor

Bonjour @kajanthangavel 

 

I wasn’t sure.

I haven’t worked on it yet because I thought it should be a complete program.
I’m out of time to do it right away, it’s pretty simple, you want to learn to do it, or you want we do it for you?

 

Question : Y coordinates must be negative in all cases?

 

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

0 Likes
Message 9 of 13

autoid374ceb4990
Collaborator
Collaborator

I am just an old civil engineer and all the profiles I have ever created or seen have the distance on the X axis and the elevation on the Y axis.  Is there a reason your profile seems (to me at least) to be rotated 90 deg.?

0 Likes
Message 10 of 13

Sea-Haven
Mentor
Mentor

Next question will be how to scale in X & Y direction.

0 Likes
Message 11 of 13

giscivil92
Advocate
Advocate

@autoid374ceb4990 Yes sure, but according to specific work I need to rotate the profile 90 degree!

0 Likes
Message 12 of 13

giscivil92
Advocate
Advocate

@Sea-Haven yes you are right , that needs a scale in y direction equals 10 times bigger than x

0 Likes
Message 13 of 13

kajanthangavel
Advocate
Advocate

Try This

Profile PRO.gif

0 Likes