Research on Key Technologies of Component-Based 3D CAD System Development (2)

2 .2 topographic section
In the design of hydropower engineering, the problem of cutting the profile on the topographic map is often encountered. With Visual Lisp, the fast cut profile can be realized.

(1) Initial topographic map processing
Transform the terrain plan with z coordinate, and transform the z coordinate value into the layer name. To speed up the cut profile, convert both “LWPOLYLINE” and “SPLINE” to “LINE” line. The procedure is as follows:
(defun c:pltol()

;LWPOLYLINE is converted to LINE

(setq n 0)

(setq e (ssget"X" (list (cons 0 "LWPOLYLINE"))))

(setq sh (sslength e))

(if e

(while (< n sh)

(setq e1 (ssname en))

(command "pedit" e1 "d" "")

(setq x (entget e1))

(setq ngc (atof (setq la (fld 8 x))))

(command "explode" e1)

(setq n (+ n 1))

) ) )

(defun fld (num lst)

(cdr (assoc num lst))

)

(defun c:spltol ()

; SPLINE is converted to LINE

(setq n 0)

(setq e (ssget "X" (list (cons 0 "SPLINE"))))

(setq sh (sslength e))

(if e

(while (< n sh)

(setq x (entget (setq e1 (ssname en))))

(setq nla (itoa (fix (cadd (fld 10 x)))))

(if (= (fld 0 x) "SPLINE")

(progn

(command "layer" "n" nla "c"

"6" nla "s" nla "")

(command"line")

(setq nm (length x)

Dzs (fld 73 x) dzs1 (fld 74 x))

(while (> nm 5)

(if (= (car (nth nm x)) 10)

(progn

(setq b1 (nth nm x))

(setq x1 (cadr b1))

(setq y1 (caddr b1))

(setq z1 (cadddr b1))

(setq glb (list x1 y1))

(command glb)

) )

(setq nm (- nm 1))

)))

(command "")

(setq n (+ n 1))

)))

(2) Cut section
Enter the section number, specify two points on the plane topographic map to determine the section line position, specify the starting point of the section map, use AutoCAD's inters function to search all intersections of the section line and the topographic map, automatically calculate the coordinates of the intersection point, calculate the intersection point and the starting point of the section position. For the distance, the coordinates of each point of the profile are formed according to the elevation of each intersection and the distance from the starting point, and the profile of the topographic map can be generated by using the coordinate line of the example 1 herein.

(defun dxtent1 ()

(setq n 0 xdzb nil)

(setq xds 0)

(setq sh (sslength e1))

(while (< n sh)

(setq x (entget (ssname e1 n)))

(if (= (fld 0 x) "LINE")

(progn

(setq dxtgcgc (fld 8 x))

(setq dxtgcgc (atoi dxtgcgc))

(if (> dxtgcgc 10)

(progn

(setq pst (fld 10 x))

(setq pet (fld 11 x))

(setq zb (list gc

(list (car pst) (cadr pst))

(list (car pet) (cadr pet))

))

(setq xdzb (cons zb xdzb))

(setq xds (+ xds 1))

))))

(setq n (+ n 1))

))

(defun c:dxtsec ()

(setq pmh (+ pmh 1))

(setq pmh (getstring "/n section number" ))

(setq pt1 (getpoint "/n starting position of the cut position: "))

(setq pt2 (getpoint pt1 "/n cut end position:"))

(setq pt3 (getpoint "/n profile layout:"))

(setq p01 pt3)

(setq e1 (ssget "F" (list pt1 pt2))); Use AutoCAD's target selection "F" to select the topographic line that intersects the section line.

(dxtent); Get the coordinates of the topographic line intersecting the section line
(setq mxgc -100)

(setq mngc 10000)

(setq m 0 pmp nil)

(setq n xds i 0)

(while (< in)

(setq crosp

(inters pt1 pt2 (nth 1 (nth i xdzb)) (nth 2 (nth i xdzb)) 1)

); find the intersection of the section line and the topographic line
(if (/= crosp nil)

(progn

(setq dxtgcgc (nth 0 (nth i xdzb)))

(setq mxgc (max mxgc dxtgcgc))

(setq mngc (min mngc dxtgcgc))

(setq dst (distance pt1 crosp)); the distance between the starting point of the section line and the intersection point
(setq dst (* (/ blcz dxthtbl) dst))

(setq pmp (cons (list m dst dxtgcgc) pmp))

(setq m (+ m 1))

))

(setq i (+ i 1))

))

Previous page next page

Reagent Grade Ammonia Solution

Liquid Ammonia,Aqueous Ammonia,Liquid Ammonia Reagent

Linqu Hengchang Chemical Co., Ltd. , http://www.hcammoniasolution.com

Posted on