lizp Posted May 17, 2009 Author Share Posted May 17, 2009 What folder is ACADDOC.lsp to be placed into? As for the animation, indeed, it's lovely. Maybe a version of the code may have it when lighter tasks are to be performed. However, when you have this amount of data to process it becomes burdensome. Although the real relief would be if the net torques are calculated correctly and are automatically placed into an Excel file. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2009 Share Posted May 17, 2009 What folder is ACADDOC.lsp to be placed into? Just put it into the ACAD Search Path - This can be changed if necessary (Tools > Options > Files (tab) > Search Path (i think)) ...and are automatically placed into an Excel file. The values can be easily copied from the CSV into any Excel file - I'm sure you don't need the program to do that for you? Quote Link to comment Share on other sites More sharing options...
lizp Posted May 17, 2009 Author Share Posted May 17, 2009 What I meant was to have the values of the net torque calculated for each individual position be saved into a separate file, the way the 8 values of the individual torques are saved into their own Excel file. Otherwise one has to open forty files to extract each net torque. First, however, the net torques have to be calculated correctly which depends on the correct determination of the signs of the individual torques. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2009 Share Posted May 17, 2009 Ok, give this a go - this will provide an Auto Method for measurement, and will also display the net value - even though this may be incorrect at this point: (defun c:vec1 (/ *error* vlst ovar doc spc Circ bVec path cCen lObj lAng lLen CirObj i tmp grdat cEnt cObj ofile pt tan angdif tandif radtan pertan tanpt norpt ptlst tBox tHgt tWid bsPt btPt tpPt flag inc tmpLin cPt net) (vl-load-com) (defun *error* (msg) (if doc (vla-regen doc acActiveViewport)) (if ovar (mapcar 'setvar vlst ovar)) (if (not (member msg '("Function cancelled" "quit / exit abort"))) (princ (strcat "\n<< Error: " msg " >>")) (princ "\n<< Function Cancelled >>")) (princ)) (setq vlst '("CLAYER" "CMDECHO" "DIMZIN") ovar (mapcar 'getvar vlst)) (mapcar 'setvar (cdr vlst) '(0 0)) (or vec:def (setq vec:def "Manual")) (or vec:inc (setq vec:inc 10.0)) (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)) spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) (vla-get-paperspace doc)) (vla-get-modelspace doc))) (if (and (setq Circ (car (entsel "\nSelect Circle: "))) (eq "CIRCLE" (cdadr (entget Circ))) (setq bVec (car (entsel "\nSelect Base Vector: "))) (member (cdadr (entget bVec)) '("LINE" "LWPOLYLINE" "POLYLINE"))) (progn (or (tblsearch "LAYER" "TORQUE-VECTORS") (vla-add (vla-get-layers doc) "TORQUE-VECTORS")) (setvar "CLAYER" "TORQUE-VECTORS") (setq path (strcat (getvar "DWGPREFIX") (substr (getvar "DWGNAME") 1 (- (strlen (getvar "DWGNAME")) 4)) ".csv") cCen (cdr (assoc 10 (entget Circ))) lObj (vlax-ename->vla-object bVec) lAng (angle '(0 0 0) (vlax-curve-getFirstDeriv bVec (vlax-curve-getStartParam bVec))) lLen (vla-get-Length lObj) CirObj (vlax-ename->vla-object Circ) i (vlax-curve-getStartParam CirObj) net 0.0) (setq ofile (open path "a")) (initget "Auto Manual") (setq tmp (getkword (strcat "\nSpecify Placement Method [Auto/Manual] <" vec:def ">: "))) (or (not tmp) (setq vec:def tmp)) (princ "\nSelect Curve: ") (while (not flag) (while (eq 5 (car (setq grdat (grread t 5 2)))) (if (and (setq cEnt (car (nentselp (cadr grdat)))) (member (cdadr (entget cEnt)) '("LWPOLYLINE" "POLYLINE" "CIRCLE" "ELLIPSE" "ARC" "LINE" "SPLINE")) (not (eq Circ cEnt))) (redraw cEnt 3) (mapcar '(lambda (x) (redraw x 4)) (mapcar 'cadr (ssnamex (ssget "_X")))))) (if cEnt (progn (cond ((eq "Manual" vec:def) (while (eq 5 (car (setq grdat (grread t 5 0)))) (redraw) (setq cObj (vlax-ename->vla-object cEnt) pt (vlax-curve-getClosestPointto cObj (cadr grdat)) tan (vlax-curve-getFirstDeriv cObj (vlax-curve-getParamatPoint cObj pt)) angdif (abs (- (angle '(0 0 0) tan) lAng)) tandif (abs (- (angle '(0 0 0) tan) (angle pt cCen))) tanpt (polar pt (angle '(0 0 0) tan) (* lLen (cos angdif))) radtan (polar pt (angle pt cCen) (* (distance pt tanpt) (cos tandif))) pertan (polar pt ((if (<= 0 (car tan)) + -) (angle pt cCen) (/ pi 2)) (* (distance pt tanpt) (sin tandif))) norpt (polar pt (+ (/ pi 2) (angle '(0 0 0) tan)) (* lLen (sin angdif))) bsvpt (polar pt lAng lLen)) (grvecs (list 3 pt tanpt 3 pt norpt 8 pt cCen 1 pt bsvpt 4 pt radtan 4 pt pertan))) (if (eq 3 (car grdat)) (progn (setq ptlst (mapcar 'vlax-3d-point (list pt tanpt norpt cCen radtan pertan bsvpt))) (vla-put-color (vla-addline spc (car ptlst) (cadr ptlst)) acGreen) (vla-put-color (vla-addline spc (car ptlst) (caddr ptlst)) acGreen) (vla-put-color (vla-addline spc (car ptlst) (cadddr ptlst)) (vla-put-color (vla-addline spc (car ptlst) (nth 4 ptlst)) acCyan) (vla-put-color (vla-addline spc (car ptlst) (nth 5 ptlst)) acCyan) (vla-put-color (vla-addline spc (car ptlst) (last ptlst)) acRed) (setq torq (* (if (<= 0 (car tan)) -1. 1.) (distance pt cCen) (distance pt pertan))) (setq net (+ torq net)) (princ (strcat "\n<< Calculated Torque: " (rtos torq 2 4) " >>\n")) (write-line (rtos torq 2 ofile) (setq tBox (textbox (list (cons 1 (rtos torq 2 4)) (cons 40 (getvar "TEXTSIZE")) (cons 7 (getvar "TEXTSTYLE")))) tHgt (- (cadadr tBox) (cadar tBox)) twid (- (caadr tBox) (caar tBox))) (princ "\nSpecify Text Position: ") (while (eq 5 (car (setq grdat (grread t 5 0)))) (redraw) (setq bsPt (cadr grdat) btPt (polar bsPt (/ (* 3 pi) 2) (/ tHgt 2.)) tpPt (polar bsPt (/ pi 2) (/ tHgt 2.))) (grvecs (list 3 (polar btPt 0 (/ tWid 2.)) (polar btPt pi (/ tWid 2.)) 3 (polar btPt 0 (/ tWid 2.)) (polar tpPt 0 (/ tWid 2.)) 3 (polar btPt pi (/ tWid 2.)) (polar tpPt pi (/ tWid 2.)) 3 (polar tpPt pi (/ tWid 2.)) (polar tpPt 0 (/ tWid 2.))))) (if (eq 3 (car grdat)) (Make_Text (cadr grdat) (rtos torq 2 4) 0.0))))) ((eq "Auto" vec:def) (initget 6) (setq inc (getreal (strcat "\nSpecify Degree Increment <" (rtos vec:inc) ">: "))) (or (not inc) (and (< 0 inc < 360) (setq vec:inc inc))) (while (< i (* 2 pi)) (setq cPt (vlax-curve-getPointatParam CirObj i)) (setq pt (car (vlax-list->3D-point (vlax-invoke (setq tmpLin (vla-addline spc (vlax-3D-point cCen) (vlax-3D-point cPt))) 'IntersectWith (setq cObj (vlax-ename->vla-object cEnt)) acExtendNone))) tan (vlax-curve-getFirstDeriv cObj (vlax-curve-getParamatPoint cObj pt)) angdif (abs (- (angle '(0 0 0) tan) lAng)) tandif (abs (- (angle '(0 0 0) tan) (angle pt cCen))) tanpt (polar pt (angle '(0 0 0) tan) (* lLen (cos angdif))) radtan (polar pt (angle pt cCen) (* (distance pt tanpt) (cos tandif))) pertan (polar pt ((if (<= 0 (car tan)) + -) (angle pt cCen) (/ pi 2)) (* (distance pt tanpt) (sin tandif))) norpt (polar pt (+ (/ pi 2) (angle '(0 0 0) tan)) (* lLen (sin angdif))) bsvpt (polar pt lAng lLen)) (vla-delete tmpLin) (setq ptlst (mapcar 'vlax-3d-point (list pt tanpt norpt cCen radtan pertan bsvpt))) (vla-put-color (vla-addline spc (car ptlst) (cadr ptlst)) acGreen) (vla-put-color (vla-addline spc (car ptlst) (caddr ptlst)) acGreen) (vla-put-color (vla-addline spc (car ptlst) (cadddr ptlst)) (vla-put-color (vla-addline spc (car ptlst) (nth 4 ptlst)) acCyan) (vla-put-color (vla-addline spc (car ptlst) (nth 5 ptlst)) acCyan) (vla-put-color (vla-addline spc (car ptlst) (last ptlst)) acRed) (setq torq (* (if (<= 0 (car tan)) -1. 1.) (distance pt cCen) (distance pt pertan))) (setq net (+ torq net)) (princ (strcat "\n<< Calculated Torque: " (rtos torq 2 4) " >>")) (Make_Text (polar cPt (angle cCen cPt) (/ (distance cCen cPt) 4.)) (rtos torq 2 4) 0.0) (write-line (rtos torq 2 ofile) (setq i (+ i (dtr vec:inc)))))) (princ "\nSelect Curve: ")) (setq flag T)) (redraw)) (setq tBox (textbox (list (cons 1 (rtos net 2 4)) (cons 40 (getvar "TEXTSIZE")) (cons 7 (getvar "TEXTSTYLE")))) tHgt (- (cadadr tBox) (cadar tBox)) twid (- (caadr tBox) (caar tBox))) (princ "\nSpecify Net Torque Text Position: ") (while (eq 5 (car (setq grdat (grread t 5 0)))) (redraw) (setq bsPt (cadr grdat) btPt (polar bsPt (/ (* 3 pi) 2) (/ tHgt 2.)) tpPt (polar bsPt (/ pi 2) (/ tHgt 2.))) (grvecs (list 3 (polar btPt 0 (/ tWid 2.)) (polar btPt pi (/ tWid 2.)) 3 (polar btPt 0 (/ tWid 2.)) (polar tpPt 0 (/ tWid 2.)) 3 (polar btPt pi (/ tWid 2.)) (polar tpPt pi (/ tWid 2.)) 3 (polar tpPt pi (/ tWid 2.)) (polar tpPt 0 (/ tWid 2.))))) (if (eq 3 (car grdat)) (Make_Text (cadr grdat) (rtos net 2 4) 0.0)) (close ofile)) (princ "\n<!> Incorrect Selection <!>")) (command "_regenall") (mapcar 'setvar vlst ovar) (princ)) (defun dtr (a) (* pi (/ a 180.0))) (defun Make_Text (pt val rot) (entmake (list (cons 0 "TEXT") (cons 8 (getvar "CLAYER")) (cons 10 pt) (cons 40 (getvar "TEXTSIZE")) (cons 1 val) (cons 50 rot) (cons 7 (getvar "TEXTSTYLE")) (cons 71 0) (cons 72 1) (cons 73 2) (cons 11 pt)))) (defun vlax-list->3D-point (lst) (if lst (cons (list (car lst) (cadr lst) (caddr lst)) (vlax-list->3D-point (cdddr lst))))) Quote Link to comment Share on other sites More sharing options...
lizp Posted May 17, 2009 Author Share Posted May 17, 2009 I see. Very neat idea and all looks pretty cool That may be the road to more sophisticated optimization concepts first adding to it automatic incrementing of the wheel's position while performing this calculation. Problem is, the track supposedly has a more complicated form -- egg-like, drop-like and so on -- and setting the radial lines evenly will not reflect the real situation. But the idea is very good and should be considered. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2009 Share Posted May 17, 2009 Ok, so I am not sure how we should proceed from here. I can't seem to get the direction of these vectors right. Quote Link to comment Share on other sites More sharing options...
SEANT Posted May 17, 2009 Share Posted May 17, 2009 I’d like to add a couple of items to the mix. The attached has a reasonably good Spline approximation (see magenta curve) that may make processing more user-friendly. I’ve also made a couple of notes that could have a bearing on the assessment of outside viewers. Another detail that may be worth noting (especially with regard to this lisp routine playing a continuing role in general torque calculations): Making some provision for describing the resulting torques as a vector with magnitude (i.e., Lever Arm Cross Product Force) would help with situations where frameworks lie on different planes. That would not affect this current problem, however, as everything here is coplanar. WithSplinePath.dwg Quote Link to comment Share on other sites More sharing options...
lizp Posted May 17, 2009 Author Share Posted May 17, 2009 Lee, I think we have to focus on the signs of the torques first. The direction of the vectors will come from there, I think. Is there a way to know what the coordinates of the extreme points of the curve (blue) are? For instance what is the point with the topmost and lowest value? If that's possible then this will allow us to set the ctiterion to judge for the signs. Quote Link to comment Share on other sites More sharing options...
lizp Posted May 17, 2009 Author Share Posted May 17, 2009 Thanks @SEANT, looks very nice. Will have to see how it works. The path problem is one of the crucial ones in this project. Quote Link to comment Share on other sites More sharing options...
SEANT Posted May 17, 2009 Share Posted May 17, 2009 Ok, so I am not sure how we should proceed from here.I can't seem to get the direction of these vectors right. If we disregard the “complexities” I alluded to in my previous post; It appears that your routine is returning the correct magnitudes, but has areas where the signs are reversed. The drawing I just re-posted has the circle centered at the origin. Maybe using the x coordinate returned from the point acquisition portion of the “Select Curve” query - in this formula ABS(Magnitude) * (-x/ABS(x)) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2009 Share Posted May 17, 2009 If we disregard the “complexities” I alluded to in my previous post; It appears that your routine is returning the correct magnitudes, but has areas where the signs are reversed. The drawing I just re-posted has the circle centered at the origin. Maybe using the x coordinate returned from the point acquisition portion of the “Select Curve” query - in this formula ABS(Magnitude) * (-x/ABS(x)) Thats a lot more succinct than my "multiple IF statement" approach of determining the sign of the vectors... As for finding the points of the extremum values of the blue curve, I can only think of iterative methods, - i.e. shuffling along the curve at intervals and picking the largest value from many. But maybe I am not quite awake today... Quote Link to comment Share on other sites More sharing options...
SEANT Posted May 17, 2009 Share Posted May 17, 2009 But maybe I am not quite awake today... It is Sunday, after all. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2009 Share Posted May 17, 2009 It is Sunday, after all. I just really don't like using iterative methods to do anything - nothing is ever precise, and it just make the program slower - I am striving for a better solution.. :wink: Quote Link to comment Share on other sites More sharing options...
SEANT Posted May 17, 2009 Share Posted May 17, 2009 Lee, I think we have to focus on the signs of the torques first. The direction of the vectors will come from there, I think. Is there a way to know what the coordinates of the extreme points of the curve (blue) are? For instance what is the point with the topmost and lowest value? If that's possible then this will allow us to set the ctiterion to judge for the signs. Ah, yes. The extremes of the Spline probably do have more bearing on torque direction calculations. I just really don't like using iterative methods to do anything - nothing is ever precise, and it just make the program slower - I am striving for a better solution.. :wink: I hear you. There may be Double Precision Floating Point issues but: What if the Bounding Box of the Spline curve was analyzed and the four lines used with an IntersectWith call? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2009 Share Posted May 17, 2009 What if the Bounding Box of the Spline curve was analyzed and the four lines used with an IntersectWith call? What an idea! Fantastic Sean Superb mate. Quote Link to comment Share on other sites More sharing options...
SEANT Posted May 17, 2009 Share Posted May 17, 2009 Ideas are easy (relatively), implementation is hard. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2009 Share Posted May 17, 2009 OK, this is driving me crazy - I have tried to implement your idea by creating a small sub-function to test it. But I keep getting a return of (nil nil), when the lines blatently intersect the object - I added a "fuzz factor" to make sure they do. I cannot see where I am going wrong here... [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] getExt [b][color=RED]([/color][/b]cObj [b][color=BLUE]/[/color][/b] fuzz doc spc cObj Minp Maxp tmp1 tmp2 Maxpt Minpt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] fuzz [b][color=#009900]1[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-Acad-Object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] spc [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]zerop[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-activespace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]=[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-mspace[/color][/b] doc[b][color=RED])[/color][/b] [b][color=Blue]:vlax-true[/color][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-modelspace[/color][/b] doc[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-paperspace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-modelspace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=DARKRED]'[/color][/b]VLA-OBJECT [b][color=RED]([/color][/b][b][color=BLUE]type[/color][/b] cObj[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cObj [b][color=RED]([/color][/b][b][color=BLUE]vlax-ename->vla-object[/color][/b] cObj[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-getBoundingBox[/color][/b] cObj [b][color=DARKRED]'[/color][/b]Minp [b][color=DARKRED]'[/color][/b]Maxp[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] Minp [b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray->list[/color][/b] Minp[b][color=RED])[/color][/b] Maxp [b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray->list[/color][/b] Maxp[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] Maxpt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b]vlax-list->3D-point [b][color=RED]([/color][/b][b][color=BLUE]vlax-invoke[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] tmp1 [b][color=RED]([/color][/b][b][color=BLUE]vla-addline[/color][/b] spc [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] Minp[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] Maxp[b][color=RED])[/color][/b] fuzz[b][color=RED])[/color][/b] [b][color=#009999]0.0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] Maxp[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b]IntersectWith cObj [b][color=Blue]acExtendNone[/color][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] Minpt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b]vlax-list->3D-point [b][color=RED]([/color][/b][b][color=BLUE]vlax-invoke[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] tmp2 [b][color=RED]([/color][/b][b][color=BLUE]vla-addline[/color][/b] spc [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] Maxp[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]+[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] Minp[b][color=RED])[/color][/b] fuzz[b][color=RED])[/color][/b] [b][color=#009999]0.0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] Minp[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b]IntersectWith cObj [b][color=Blue]acExtendNone[/color][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] Minpt Maxpt[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] vlax-list->3D-point [b][color=RED]([/color][/b]lst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] lst [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] lst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] lst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]caddr[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]vlax-list->3D-point [b][color=RED]([/color][/b][b][color=BLUE]cdddr[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:test [b][color=RED]([/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]getExt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entsel[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] Quote Link to comment Share on other sites More sharing options...
SEANT Posted May 17, 2009 Share Posted May 17, 2009 That is irritating. I’ve also had inconsistent results from the ActiveX IntersectWith method (http://www.cadtutor.net/forum/showthread.php?t=33740). In this particular instance a 3d poly may be more cooperative. The “managed” api also offers Curve2d.GetClosestPointTo Method (Curve2d). That would be a .NET way to deal with the precision issue with trying to find a tangential curve/curve intersection. This thread has me interested in exploring torque calculation from the .NET api. I would be about a hundred times slower at code generation, though. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2009 Share Posted May 17, 2009 I've never done Torque Calculations, so this is a first for me... and I know nothing about the .NET API... so I think I'd be even slower... :P Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 17, 2009 Share Posted May 17, 2009 Thanks Sean [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] getExt [b][color=RED]([/color][/b]cObj [b][color=BLUE]/[/color][/b] fuzz doc spc cObj Minp Maxp tmp1 tmp2 Maxpt Minpt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] fuzz [b][color=#009999]0.00001[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-Acad-Object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] spc [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]zerop[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-activespace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]=[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-mspace[/color][/b] doc[b][color=RED])[/color][/b] [b][color=Blue]:vlax-true[/color][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-modelspace[/color][/b] doc[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-paperspace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-modelspace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=DARKRED]'[/color][/b]VLA-OBJECT [b][color=RED]([/color][/b][b][color=BLUE]type[/color][/b] cObj[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cObj [b][color=RED]([/color][/b][b][color=BLUE]vlax-ename->vla-object[/color][/b] cObj[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-getBoundingBox[/color][/b] cObj [b][color=DARKRED]'[/color][/b]Minp [b][color=DARKRED]'[/color][/b]Maxp[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] Minp [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]function[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b]x[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]+[/color][/b] x fuzz[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray->list[/color][/b] Minp[b][color=RED])[/color][/b][b][color=RED])[/color][/b] Maxp [b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]function[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b]x[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] x fuzz[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray->list[/color][/b] Maxp[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] Maxpt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b]vlax-list->3D-point [b][color=RED]([/color][/b][b][color=BLUE]vlax-invoke[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] tmp1 [b][color=RED]([/color][/b][b][color=BLUE]vla-addline[/color][/b] spc [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] Minp[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] Maxp[b][color=RED])[/color][/b] [b][color=#009999]0.0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] Maxp[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] Maxp[b][color=RED])[/color][/b] [b][color=#009999]0.0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b]IntersectWith cObj [b][color=Blue]acExtendNone[/color][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] Minpt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b]vlax-list->3D-point [b][color=RED]([/color][/b][b][color=BLUE]vlax-invoke[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] tmp2 [b][color=RED]([/color][/b][b][color=BLUE]vla-addline[/color][/b] spc [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] Maxp[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] Minp[b][color=RED])[/color][/b] [b][color=#009999]0.0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] Minp[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] Minp[b][color=RED])[/color][/b] [b][color=#009999]0.0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=DARKRED]'[/color][/b]IntersectWith cObj [b][color=Blue]acExtendNone[/color][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] Minpt Maxpt[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] vlax-list->3D-point [b][color=RED]([/color][/b]lst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] lst [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] lst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] lst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]caddr[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]vlax-list->3D-point [b][color=RED]([/color][/b][b][color=BLUE]cdddr[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:test [b][color=RED]([/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setvar[/color][/b] [b][color=#ff00ff]"PDMODE"[/color][/b] [b][color=#009900]3[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]foreach[/color][/b] pt [b][color=RED]([/color][/b]getExt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entsel[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]command[/color][/b] [b][color=#ff00ff]"_point"[/color][/b] [b][color=#ff00ff]"_non"[/color][/b] pt[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] 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.