DRAW Profile line by value of Y-Axis from xline

DRAW Profile line by value of Y-Axis from xline

SAFizzy
Advocate Advocate
612 Views
9 Replies
Message 1 of 10

DRAW Profile line by value of Y-Axis from xline

SAFizzy
Advocate
Advocate

Dear All,

I want to draw profile line having ground level slope with the help of lisp by just providing distance from X-Line which can be baseline from any position. i can provide the points or grips of required levels. 

 

0 Likes
613 Views
9 Replies
Replies (9)
Message 2 of 10

john.uhden
Mentor
Mentor

@SAFizzy ,

Please correct me if I am wrong.

You want to create a profile relative to the XLine as though the XLine were were the X-axis, is that correct?

I presume that you would select Points or other objects with insertion points or centers, etc.

My perception is that you would:

1.  Select the XLine.

2.  Select the points to profile and put them in a list.

3.  For each point get the corresponding point nearest (which would be perpendicular to the XLine) and create a new list in the form of '((x1 y1)(x2 y2) etc.)) where x is the distance along the XLine from its beginning to the perpendicular point and Y is the distance from the input point perpendicular to the XLine.

4.  Sort the XY line ascending from the lowest distance along the XLine to the greatest.

5.  Create a polyline from the sorted values.

 

Can you write AutoLisp or does one of us have to write it for you?

 

John F. Uhden

Message 3 of 10

Kent1Cooper
Consultant
Consultant

Your drawing contains no XLINE.  That word has a specific meaning in AutoCAD.  If it means something different to you, can you explain differently?

Kent Cooper, AIA
0 Likes
Message 4 of 10

SAFizzy
Advocate
Advocate
@john.uhden
Thanks for brief reply,
yes you got it correctly & my point is to draw profile line which is shown in sample file in (Blue line ,not correctly drawn) where as the (XLine) is the (Green line) drawn as reference (X Axis). The values are given in ground level Layer e.g.(@Grid 246 & 247) 90.094m & 90.107m.
now the point is that, if we write Autolisp to take values from ground levels and take distance from manually given line along X-Axis (parallels to Boundary Wall Layout) and draw profile line with lips command.
At last sorry 🙏 i am not expert in writing Lisp.

Regards
0 Likes
Message 5 of 10

SAFizzy
Advocate
Advocate
appologize for that, Yes AutoCAD Xline mean something different, but I mean if we put Line along X-Axis or Xline and code will get the values of levels with coordinates from specific layer & draw profile line automatically
0 Likes
Message 6 of 10

Sea-Haven
Mentor
Mentor

This I think is a re-question of a previous post, where objects are a distance from a base line, but they went around the corner and the base line value changed. Will try to find. 

 

In civil works have what is known as a Peg & shift. Comparing a base line to another.

 

In terms of an offset pline can be done as always relevant square off, but base line level does not change. See green pline in dwg.If I am understanding correctly.

Message 7 of 10

john.uhden
Mentor
Mentor

@SAFizzy ,

Um, what about if the XLine is drawn generally from right to left?  In that case the procedure I mentioned would also draw the profile from right to left.  Is that okay, or would you want something that always draws the profile from left to right?  Of course if you use Dview;Twist, then both can be displayed from left to right if needed.  Please don't tell me about oddball UCSs.  We civils generally despise any UCS other than World.

John F. Uhden

0 Likes
Message 8 of 10

SAFizzy
Advocate
Advocate
basically, i need to draw profile line from given data, either in CAD (with in the file) or Excel. it can be drawn anywhere as long as i am getting the profile line correct. then i can move it in desired location. so UCS also not a big problem, but if possible then better to be drawn in front of layout.
THanks
0 Likes
Message 9 of 10

Sea-Haven
Mentor
Mentor

So have base line green, then draw the blue line based on values from a excel file, I am trying to find the other post it had the answer, I am sure it was here. Had chainage and offset in Excel. Found the Excel, but not the post.

SeaHaven_0-1694303372410.png

Found it how to create Dimensions in given chainage with given depth? - Autodesk Community - AutoCAD

0 Likes
Message 10 of 10

Sea-Haven
Mentor
Mentor

Try this, expects a 2 columns Excel with 1st row as headings. Open the excel before running.

SeaHaven_0-1694324154198.png

I am guessing some stuff as no data on what the surface file looks like. 

 

; draw a surface long section based on excel file chainage and level
; By AlanH Sept 2023

(defun c:longexcel ( / getcell myxl radd end st rows rownum)
(defun getcell (cellname / )
(setq myRange (vlax-get-property  (vlax-get-property myxl "ActiveSheet") "Range" cellname))
(princ  (vlax-variant-value (vlax-get-property myRange 'Value2)))
)

(defun getrangexl ( / lst UR CR RADD )
(setq lst '())
(setq UR (vlax-get-property  (vlax-get-property myxl "ActiveSheet") "UsedRange"))
(setq CR (vlax-get-property UR "CurrentRegion"))
(setq RADD (vlax-get-property CR "Address"))
(setq cnt (vlax-get-property CR  "Count"))
(setq lst (_csv->lst58 radd))
(setq st (vl-string-subst "" "$" (vl-string-subst "" "$" (nth 0 lst) )))
(setq end (vl-string-subst "" "$" (vl-string-subst "" "$" (nth 1 lst) )))
(setq st  (columnrow st))
(setq end  (columnrow end))
(princ st)
(princ "\n")
(princ end)
)

; thanks to Lee-mac for this defun 
; www.lee-mac.com
; 44 is comma 9 is tab 34 is space 58 is colon
(defun _csv->lst58 ( str / pos )
	(if (setq pos (vl-string-position 58 str))
		(cons (substr str 1 pos) (_csv->lst58 (substr str (+ pos 2))))
		(list str)
    )
)

; ColumnRow - Returns a list of the Column and Row number
; Function By: Gilles Chanteau from Marseille, France
; Arguments: 1
;   Cell$ = Cell ID
; Syntax example: (ColumnRow "ABC987") = '(731 987)
;default to "A1" if there's a problem
;-------------------------------------------------------------------------------
(defun ColumnRow (Cell$ / Column$ Char$ Row#)
  (setq Column$ "")
  (while (< 64 (ascii (setq Char$ (strcase (substr Cell$ 1 1)))) 91)
    (setq Column$ (strcat Column$ Char$)
          Cell$ (substr Cell$ 2)
    )
  )
  (if (and (/= Column$ "") (numberp (setq Row# (read Cell$))))
    (list (Alpha2Number Column$) Row#)
    '(1 1)
  )
)

; Alpha2Number - Converts Alpha string into Number
; Function By: Gilles Chanteau from Marseille, France
; Arguments: 1
;   Str$ = String to convert
; Syntax example: (Alpha2Number "ABC") = 731
;-------------------------------------------------------------------------------
(defun Alpha2Number (Str$ / Num#)
  (if (= 0 (setq Num# (strlen Str$)))
    0
    (+ (* (- (ascii (strcase (substr Str$ 1 1))) 64) (expt 26 (1- Num#)))
       (Alpha2Number (substr Str$ 2))
    )
  )
)

(defun LWPoly (lst cls)
 (entmakex (append (list (cons 0 "LWPOLYLINE")
                         (cons 100 "AcDbEntity")
                         (cons 100 "AcDbPolyline")
                         (cons 90 (length lst))
                         (cons 70 cls))
                   (mapcar (function (lambda (p) (cons 10 p))) lst))))
				   
;;;;;;;;;;;;;;;;; starts here

(or
(setq myxl (vlax-get-object "Excel.Application"))
    (setq myxl (vlax-get-or-create-object "excel.Application"))
)
; (vlax-invoke-method (vlax-get-property myXL 'WorkBooks) 'Add)
(vla-put-visible myXL :vlax-true)
(vlax-put-property myxl 'ScreenUpdating :vlax-true)
(vlax-put-property myXL 'DisplayAlerts :vlax-true)

(getrangexl)
(setq rownum (+ (cadr st) 1)) ; add 1 so skip heading
(setq rows (+ 1 (- (cadr end) rownum)))

(setq pt (getpoint "pick point for start left end "))
(setq x (car pt) y (cadr pt))

(setq lst '())
(repeat rows
(setq dist (getcell (strcat "A" (rtos rownum 2 0))))
(setq ht (getcell (strcat "B" (rtos rownum 2 0))))
(setq newpt (list (+ dist x) (+ ht y)))
(setq lst (cons newpt lst))
(setq rownum (1+ rownum))
)
(setq lst (reverse lst))
(lwpoly lst 0)
(command "line" pt (polar pt 0.0 dist) "")
(princ)
)
0 Likes