CraneGuy Posted January 27, 2009 Share Posted January 27, 2009 Hi there! Hope someone can help me. I have to create multiple simple shapes from given data. Its easy to do manually but very annoying. We are provided information by the railroads to show a "clearance window" that rail loads can pass through. This window reflects obstructions along the rail route. The data given is a height above the rail, and a width at the given height. My process at the moment is to choose a base point, draw a vertical line to the given height, then another line horizontally at the given width. I then pull the line over by the center grip to the top of the vertical line. I repeat this until all the lines are in place, then link the end points with a polyline (from the base point) (See attachment) I then delete the interior horizontal and vertical lines. This leaves me with an outline I can place over the end elevation of the railcar and it's load. The data is given in the following format (ATR means Above Track): 16 ft. 11 in. atr 08 ft. 02 in. wide 16 ft. 08 in. atr 09 ft. 02 in. wide 16 ft. 07 in. atr 11 ft. 08 in. wide 16 ft. 02 in. atr 12 ft. 02 in. wide 14 ft. 04 in. atr 12 ft. 06 in. wide 05 ft. 04 in. atr 12 ft. 06 in. wide 05 ft. 03 in. atr 12 ft. 00 in. wide 04 ft. 01 in. atr 12 ft. 00 in. wide 03 ft. 05 in. atr 11 ft. 06 in. wide 03 ft. 04 in. atr 10 ft. 02 in. wide 02 ft. 05 in. atr 10 ft. 01 in. wide Is it possible to create a lisp routine that will ask for these numbers and produce the polyline? Thanks in advance! Clearance Window.pdf Quote Link to comment Share on other sites More sharing options...
fixo Posted January 27, 2009 Share Posted January 27, 2009 I don't understand what you exactly need Perhaps this routine will helps (defun C:shw (/ data fdesc fname lastp pline points tmp) (setq fname (getfiled "Select data file:" "C:\\" "txt;csv;dat" 4)) (setq fdesc (open fname "r")) (while (setq tmp (read-line fdesc)) (setq data (cons tmp data)) ) (close fdesc) (princ data) (if data (progn (setq data (mapcar (function (lambda (x) (vl-string-subst "," "atr" x))) (reverse data))) (setq points (mapcar (function (lambda (x) (setq lastp (substr x (+ 4 (vl-string-search " ," x)))) (list (+ (atof x) (/ (atof (substr x (+ (vl-string-search " ft." x) 5) (+ 3 (vl-string-search " in. " (car data))))) 12)) (+ (atof lastp) (/ (atof (substr lastp (+ (vl-string-search " ft." lastp) 5) (+ 3 (vl-string-search " in. " lastp)))) 12))))) data) ) (setvar "osmode" 0) (command "._pline") (mapcar 'command points) (command "") (setq pline (entlast)) (command "._zoom" "_OB" pline "") (command "._zoom" ".6x") (alert "Pick two mirror points, use snap") (command ".mirror" pline "" pause pause "_n") (setq mirr (entlast)) (alert "Pick two line points to close contour, use snap") (command "._line" pause pause "") (setq line (entlast)) (command "._pedit" "_M" pline mirr line "" "J" "" "") (command "._regen") ) (alert "Something wrong") ) (princ) ) (princ "Type SHW to execute") (princ) ~'J'~ Quote Link to comment Share on other sites More sharing options...
CraneGuy Posted January 27, 2009 Author Share Posted January 27, 2009 That's pretty amazing code, thanks. What I basically need it to do is to create the red outline in the attached PDF. The numbers are widths at certain heights (Black lines). The polyline (red) is drawn afterwards to connect the end points of each line; this creates an outline joined to a base point. The basepoint would be 0 height and 0 width. I ran your routine, and it created a shape. The problem is I cannot choose a mirror point. The code could choose the base point automatically. Also, the first dimension came it at 4" instead of 10'-1" Also, the outline is on its side. I hope you understand what I'm looking for. You've been a great help so far, thanks! Quote Link to comment Share on other sites More sharing options...
fixo Posted January 28, 2009 Share Posted January 28, 2009 Oh, yes, it's happens by my stupidity, but I don't understand at all Can you create some scratch where you will be draw all of points in order how they was written in the text file according to its position? In other words, what are means every line of text file data? Sorry for my bad English ~'J'~ 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.