I was recently experimenting with command EDGESURF where variables SURFTAB1 & SURFTAB2 have been specified... Now I am not satisfied with equal and even surface division, so I am interested in obtaining point on surface (say 2nd in M direction, and 2nd in N direction, where (> (and surftab1 surftab2) 2), but now I don't want to start EDGESURF command, neither to set suftab1 and surftab2... I am interested just to calculate point, but with combination of alternative division of edge curves...
I specified types of alternative division of curves in routine as (more points density near <S>tart point, near <E>nd point, near <B>oth start & end points, near <M>iddle point, of finaly <C>lassic division with equal and even array of points)... Routine :
Code:
(defun c:divalternate ( / DPT ENT ENTA IZB K L N NN NP NR OSCMD PT PTL X Z)
(command "ucs" "w")
(setq oscmd (getvar 'osmode))
(setvar 'osmode 0)
(setq ent (car (entsel "\nPick 2D or 3D curve entity for division with more points density")))
(setq n (getint "\nInput number for division : "))
(setq nr (atof (itoa n)))
(initget 7 "Start End Both Middle Classic")
(setq izb (getkword "\nInput where is more points density (Start, End, Start&End -
Both, Middle) or Classic even and equal division <S,E,B,M,C> : "))
(vl-load-com)
(setq entA (vlax-ename->vla-object ent))
(setq l (vlax-curve-getDistAtPoint entA (vlax-curve-getEndPoint entA)))
(if (eq izb "Start")
(progn
(setq k -1)
(setq x (/ l (/ (* nr (+ nr 1)) 2)))
(repeat (fix (+ nr 1))
(setq k (+ k 1))
(setq dpt (* (/ (* k (+ k 1)) 2) x))
(setq pt (vlax-curve-getPointAtDist entA dpt))
(command "point" pt)
)
))
(if (eq izb "End")
(progn
(setq k (fix (+ nr 1)))
(setq x (/ l (/ (* nr (+ nr 1)) 2)))
(repeat (fix (+ nr 1))
(setq k (- k 1))
(setq dpt (- l (* (/ (* k (+ k 1)) 2) x)))
(setq pt (vlax-curve-getPointAtDist entA dpt))
(command "point" pt)
)
))
(if (eq izb "Both")
(progn
(setq np (/ nr 2))
(if (= np (atof (itoa (fix np))) )
(progn
(setq k -1)
(setq x (/ l (/ (* np (+ np 1)) 1)))
(repeat (fix np)
(setq k (+ k 1))
(setq dpt (* (/ (* k (+ k 1)) 2) x))
(setq pt (vlax-curve-getPointAtDist entA dpt))
(command "point" pt)
)
(setq k (fix (+ np 1)))
(setq x (/ l (/ (* np (+ np 1)) 1)))
(repeat (fix (+ np 1))
(setq k (- k 1))
(setq dpt (- l (* (/ (* k (+ k 1)) 2) x)))
(setq pt (vlax-curve-getPointAtDist entA dpt))
(command "point" pt)
)
)
(progn
(setq nn (+ nr 1))
(setq np (/ nn 2))
(setq k -1)
(setq x (/ l (expt (/ (+ nr 1) 2) 2)))
(repeat (fix np)
(setq k (+ k 1))
(setq dpt (* (/ (* k (+ k 1)) 2) x))
(setq pt (vlax-curve-getPointAtDist entA dpt))
(command "point" pt)
)
(setq k (fix np))
(setq x (/ l (expt (/ (+ nr 1) 2) 2)))
(repeat (fix np)
(setq k (- k 1))
(setq dpt (- l (* (/ (* k (+ k 1)) 2) x)))
(setq pt (vlax-curve-getPointAtDist entA dpt))
(command "point" pt)
)
))
))
(if (eq izb "Middle")
(progn
(setq np (/ nr 2))
(if (= np (atof (itoa (fix np))) )
(progn
(setq k (fix (+ np 1)))
(setq x (/ l (/ (* np (+ np 1)) 1)))
(repeat (fix (+ np 1))
(setq k (- k 1))
(setq dpt (- (/ l 2) (* (/ (* k (+ k 1)) 2) x)))
(setq pt (vlax-curve-getPointAtDist entA dpt))
(command "point" pt)
)
(setq k 0)
(setq x (/ l (/ (* np (+ np 1)) 1)))
(repeat (fix np)
(setq k (+ k 1))
(setq dpt (+ (/ l 2) (* (/ (* k (+ k 1)) 2) x)))
(setq pt (vlax-curve-getPointAtDist entA dpt))
(command "point" pt)
)
)
(progn
(setq nn (+ nr 1))
(setq np (/ nn 2))
(setq z 0)
(setq k -1)
(setq x (/ l (/ (+ (expt nr 2) (* nr 4) (- 1)) 4)))
(repeat (fix np)
(setq k (+ k 1))
(setq z (+ z k 1))
(if (= k 0) (setq z 0))
(setq dpt (- (/ l 2) (+ (/ x 2) (* z x))))
(setq pt (vlax-curve-getPointAtDist entA dpt))
(setq ptl (cons pt ptl))
)
(setq ptl (reverse ptl))
(foreach pt ptl (command "point" pt))
(setq k -1)
(setq z 0)
(setq x (/ l (/ (+ (expt nr 2) (* nr 4) (- 1)) 4)))
(repeat (fix np)
(setq k (+ k 1))
(setq z (+ z k 1))
(if (= k 0) (setq z 0))
(setq dpt (+ (/ l 2) (+ (/ x 2) (* z x))))
(setq pt (vlax-curve-getPointAtDist entA dpt))
(command "point" pt)
)
))
))
(if (eq izb "Classic")
(progn
(setq k -1)
(setq x (/ l nr))
(repeat (fix (+ nr 1))
(setq k (+ k 1))
(setq dpt (* k x))
(setq pt (vlax-curve-getPointAtDist entA dpt))
(command "point" pt)
)
))
(setvar 'pdmode 3)
(setvar 'pdsize 0)
(setvar 'osmode oscmd)
(princ)
)
If someone knows how EDGESURF, or LOFT with 2 crosssections curve entity edges and 2 guide curve entity edges, functions, any help would be appreciated... Maybe for this I need to obtain formula for surface and I don't know how... Or it would be even better if someone could construct this surface net with 3DFACE objects, but with points on edges with combination of this alternative division...
BTW, I don't know how to apply this alternative division for 3D curves as
(vlax-curve-getPointAtDist entA dpt) function functions only for 2D splines, or 2D plines, or 2D 3Dpolylines...
I actually don't know, now I test it with 3D 3Dpoly, 3D spline, 3D helix and it worked (maybe earlier something was different with my CAD)
M.R.