Jump to content

Cross_ Section.


sudam

Recommended Posts

Hi friends i m new  in lisp.

i have regularly required cross section profile for  mines activity. any one can help me for cross section or 3d line profile. pls pls pls help me . 

for more details i had attached my file. 

pls pls pls help me. 

Cross section.dwg

Link to comment
Share on other sites

This was CIV3D and Civil site design, 100m wide cross section 6 minutes and some 40 cross sections produced. just a case of changing some limits etc could be to full limit of surface.

 

If you have Briscad or Autocad then www.civilsurveysolutions.com.au will do so much more. But yes at a price.

 

image.png.4b975e604f679dad431db42b186aed73.png

 

 

 

Edited by BIGAL
Link to comment
Share on other sites

Here is a basic solution:

(defun KGA_List_LastRemove (lst)
  (reverse (cdr (reverse lst)))
)

(defun c:CreateCrossSection ( / doc end enm fac lin lst ss sta vec)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-endundomark doc)
  (vla-startundomark doc)
  (setvar 'cmdecho 0)
  (if
    (and
      (= 1 (getvar 'worlducs))
      (equal '(0.0 0.0 1.0) (getvar 'viewdir))
      (setq lin (car (entsel "\nSelect line for cross section: ")))
      (setq vec (getpoint "\nInsertion point for section: "))
      (setq fac (getreal "\nHeight factor: "))
      (progn (command "_.zoom" "_object" lin "") T)
      (setq lin (entget lin))
      (= "LINE" (cdr (assoc 0 lin)))
      (setq sta (KGA_List_LastRemove (cdr (assoc 10 lin))))
      (setq end (KGA_List_LastRemove (cdr (assoc 11 lin))))
      (setq ss (ssget "_F" (list sta end) '((0 . "POLYLINE") (-4 . "&=") (70 . 8))))
      (progn (command "_.zoom" "_previous") T)
    )
    (progn
      (setq lst
        (vl-remove
          nil
          (mapcar
            '(lambda (itm)
              (if
                (and (listp itm) (= 0 (car itm)))
                (list (distance sta (KGA_List_LastRemove (cadr itm))) (caddr (cadr itm)))
              )
            )
            (apply 'append (ssnamex ss))
          )
        )
      )
      ;; Sort points:
      (setq lst
        (vl-sort
          lst
          '(lambda (a b) (< (car a) (car b)))
        )
      )
      ;; Remove duplicate points:
      (setq lst
        (vl-remove
          nil
          (mapcar
            '(lambda (cur prev)
              (if (equal cur prev 1e-8) nil cur)
            )
            lst
            (cons nil lst)
          )
        )
      )
      ;; Calculate point for LW poly:
      (setq vec (mapcar '* '(1.0 1.0 0.0) vec))
      (setq lst
        (mapcar
          '(lambda (pt)
            (list (+ (car pt) (car vec)) (+ (* fac (cadr pt)) (cadr vec)))
          )
          lst
        )
      )
      ;; Create LW poly:
      (vlax-invoke (vla-get-modelspace doc) 'addlightweightpolyline (apply 'append lst))
      ;; Create base line:
      (vlax-invoke (vla-get-modelspace doc) 'addline vec (mapcar '+ vec (list (distance sta end) 0.0 0.0)))
      (command "_.zoom" "_extents")
    )
  )
  (setvar 'cmdecho 1)
  (vla-endundomark doc)
  (princ)
)

 

Link to comment
Share on other sites

Roy, your code is probably fine in BricsCAD, but when I test it under A2018, my (ssnamex ss) is returning wrong Z coordinate of ssget-fence intersection points... I don't know if this is the case and with others who have A2018 (I recently reinstalled it, so maybe that process bugged my CAD), but nevertheless I found solution to this particular case...

I changed this :

      (setq lst
        (vl-remove
          nil
          (mapcar
            '(lambda (itm)
              (if
                (and (listp itm) (= 0 (car itm)))
                (list (distance sta (KGA_List_LastRemove (cadr itm))) (caddr (cadr itm)))
              )
            )
            (apply 'append (ssnamex ss))
          )
        )
      )

To this :

      (setq lst
        (vl-remove
          nil
          (mapcar
            '(lambda (itm)
              (if
                (and (listp itm) (= 0 (car itm)))
                (list (distance sta (KGA_List_LastRemove (cadr itm))) (caddr (vlax-curve-getclosestpointtoprojection (vl-some '(lambda (x) (if (= (type x) 'ename) x)) (vl-member-if '(lambda (x) (equal x itm)) (reverse (apply 'append (ssnamex ss))))) (KGA_List_LastRemove (cadr itm)) '(0.0 0.0 1.0))))
              )
            )
            (apply 'append (ssnamex ss))
          )
        )
      )

And it seems that this mod. fixed the problem...

I only don't know why is now my CAD buggy... Can someone verify this issue with OP's posted DWG and AutoCAD testing?

Does someone had this problem and was the solution found? (z coordinates are always with the same value although it's obvious that they should differ...)

 

Thanks for your input, M.R.

Edited by marko_ribar
Link to comment
Share on other sites

I did respond as its a CIVIL Engineering question, so the freebie answer is here at Cadtutor its a triangulation solution by YMG just search I think it has had cross sections added. There are some others out there also just google Triangulation & Lisp. I have been involved in this type of thing since Green screen PC's.

 

Roy_043 I would not spend the time it is reinventing the wheel. I produced  40 sheets with 3 cross sections per sheet it takes about 15 seconds to change parameters like Hor and Ver scales and a regen reproduces the sheets.

 

The dwg provided appears to have been produced in CIV3D so why not cross sections produced ? It would have been far more accurate to have started with a triangulation which probably exists but was not in dwg.

 

.

Edited by BIGAL
Link to comment
Share on other sites

  • 1 month later...

Hi marco nice code. can you update  the code to write the elevetion and the distance  through specific point .

 

For example  i have my center line with the name  layer name "axon" and my cross section lines with the  layer name  "sections".

 

 want to select first the layer "axon"  (the zero length mast be on axon and at the left we ha (- length) and for the right (+ length)) and second select all the sections and create all the sections in al list with section numbers  d1,d2,d3,d4 ......

 

 

Thanks

test.dwg

Link to comment
Share on other sites

13 hours ago, prodromosm said:

hi pmadhwal7 .  No this lisp dont help me. I need samething for cross sections no long sections. Something to export this 

 

1.jpg

 

 

 

u can draw cross section too with help of this lsp....

Link to comment
Share on other sites

No you don't. The 0 is not all the time in the midle. You have to select the aligment line and then the section .So you sure that the 0 is in the corect place. In some times you will a cross section from -20 to +40

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...