Jump to content

Routine for Decomposition of Vectors


lizp

Recommended Posts

And, this, if possible 'appload' vec.lsp only once for all eight or whatever number of calculations.

 

This can be achieved by either putting the LISP file in the start-up suite or adding a call to it in the ACADDOC.lsp. :)

Link to comment
Share on other sites

  • Replies 231
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    107

  • lizp

    99

  • SEANT

    24

  • The Buzzard

    2

Top Posters In This Topic

Posted Images

As for the signs of the derivatives, the check should be as to whether or not the radial line is to the left or to the right of the point on the curve where the second derivative is zero. If it's to the left then the torque is positive, if it's to the right torque is negative.

 

I'm very sorry, but could you possibly upload a 2004 format drawing depicting exactly the position of how you want the vectors, and illustrating when it should be positive or negative.

 

You say, when the second derivative is zero, hence the extremums of the first derivative, but which curve are we talking about?

 

Sorry if I sound a little confused, but I want to get this right :)

Link to comment
Share on other sites

As for the continuity of the selections, try this (I have reverted back to an earlier code post) - without any sign checking.

 

(defun c:vec  (/       *error* vlst    ovar    doc     spc     Circ    bVec    path    cCen
              lObj    lAng    lLen    grdat   cEnt    ofile   pt      tan     angdif  tandif
              radtan  pertan  tanpt   norpt   ptlst   tBox    tHgt    tWid    bsPt    btPt
              tpPt    flag)
 (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 '("CMDECHO" "DIMZIN")
       ovar (mapcar 'getvar vlst))
 (mapcar 'setvar vlst '(0 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
     (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))
     (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
           (setq ofile (open path "a"))
           (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
                                 (- (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 (* (distance pt cCen) (distance pt pertan)))
               (princ (strcat "\n<< Calculated Torque: " (rtos torq 2 4) " >>\n"))
               (write-line (rtos torq 2  ofile)
               (close 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))))
           (princ "\nSelect Curve: "))
         (setq flag T))
       (redraw)))
   (princ "\n<!> Incorrect Selection <!>"))
 (command "_regenall")
 (mapcar 'setvar vlst ovar)
 (princ))

(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))))

Link to comment
Share on other sites

Here's an example of correct sense the vectors should have (see attached). If you try these with the code you'll see that some vectors are reversed.

 

The curve whose extremums are sought is the blue curve. Wonder if there wouldn't be another method, different from determining the second derivative because the "curve" in fact consists of small segments. Say, finding the largest and the lowest y-axis value of any point of that curve. Maybe, any radial line consisting of points with y-axis value greater that the y-axis value of the center on the one hand and having no x-axis points to the right of the x-axis value of the topmost point on the curve (we should have that value from the earlier test) would set the sign of the torque calculated with that radial line as positive. However, if any such radial line (having all y-axis points above the y-axis of the center) has x-axi points to the right of the x-axis of the topmost point on the blue curve (we already have this x-axis value from the previous test) then the torque in which the observed radial line participates is negative. What do you think about this method?

example.dxf

Link to comment
Share on other sites

Yes, that last code is excellent. Now we have to work on the sense of vectors and, most importantly, on the signs of the torques.

Link to comment
Share on other sites

This can be achieved by either putting the LISP file in the start-up suite or adding a call to it in the ACADDOC.lsp. :)

 

How do you do that? Have no idea.

Link to comment
Share on other sites

How do you do that? Have no idea.

 

Ok, if you want to go down the Start-up Suite route, just go to _appload, and click on Start-up Suite, and add the file to it.

 

If you want to use the ACADDOC.lsp, search for the file first, and if it doesn't exist, create it in Notepad, and add this to it:

 

(load "filepath/vec.lsp")

 

where filepath is a valid filepath :)

Link to comment
Share on other sites

Why is the blue curve made up of so many segments? Can't it be just one Polyline? The routine would work a lot better than way, and it would be much easier to work with.

Link to comment
Share on other sites

Why is the blue curve made up of so many segments? Can't it be just one Polyline? The routine would work a lot better than way, and it would be much easier to work with.

 

See, that's probably the biggest constructive problem in that whole project. That the gist of the whole thing and the point of optimization. It should be smooth and the Polyline isn't smooth enough. The spline cannot be shaped as needed and it has nodes. I don't know, this has to be really though over. At the moment what I thought might be the solution is to use the table of all the data that belong to the blue curve and and use them for testing the position of the radial line. Do you think that's possible. It will work even if ther's an analytical line, I think.

Link to comment
Share on other sites

Calculations would be a hell of a lot easier on one complete curve, and the program would flow a lot better.

 

See my attached drawing to see what I mean.

 

I hope I have sorted the problem with signs:

 

(defun c:vec  (/       *error* vlst    ovar    doc     spc     Circ    bVec    path    cCen
              lObj    lAng    lLen    grdat   cEnt    ofile   pt      tan     angdif  tandif
              radtan  pertan  tanpt   norpt   ptlst   tBox    tHgt    tWid    bsPt    btPt
              tpPt    flag)
 (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 '("CMDECHO" "DIMZIN")
       ovar (mapcar 'getvar vlst))
 (mapcar 'setvar vlst '(0 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
     (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))
     (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
           (setq ofile (open path "a"))
           (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)))
               (princ (strcat "\n<< Calculated Torque: " (rtos torq 2 4) " >>\n"))
               (write-line (rtos torq 2  ofile)
               (close 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))))
           (princ "\nSelect Curve: "))
         (setq flag T))
       (redraw)))
   (princ "\n<!> Incorrect Selection <!>"))
 (command "_regenall")
 (mapcar 'setvar vlst ovar)
 (princ))

(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))))

example-1.dwg

Link to comment
Share on other sites

Something isn't right. I could only make it run once and it wasn't giving me the right signs.

 

The example looks good. Will have to try it once we fix the sign issue. Turns out it is more important than I thought. At certain positions the torques at around 12 and 6 o'clock play a role and correct determination of their sign is important. What method did you apply to deal with the sign?

Link to comment
Share on other sites

To deal with the signs I took the direction of the tangent vector in the different quadrants.

 

Not sure why you could only make it run once though... the loop is still in there.

Link to comment
Share on other sites

Something is wrong with my AutoCAD probably. Now I was able to run it and it appears that signs which appear are connected with the slope of the curve. This shouldn't be, if I've understood it correctly. The signs of the torques are solely dependent on the direction of rotation these torques make the wheel turn. Thus, all torques on the right-hand side tend to turn the wheel CW (negative torques) while all the torques on the left-had side, CCW (positive torques). It appears that the difference in sign is depending on whether or not the lever causing the torque is above or below the horizontal line that passes through the center.

Link to comment
Share on other sites

Ahh, my mistake - I used the wrong part of the derivative, give this a shot:

 

(defun c:vec  (/       *error* vlst    ovar    doc     spc     Circ    bVec    path    cCen
              lObj    lAng    lLen    grdat   cEnt    ofile   pt      tan     angdif  tandif
              radtan  pertan  tanpt   norpt   ptlst   tBox    tHgt    tWid    bsPt    btPt
              tpPt    flag)
 (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 '("CMDECHO" "DIMZIN")
       ovar (mapcar 'getvar vlst))
 (mapcar 'setvar vlst '(0 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
     (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))
     (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
           (setq ofile (open path "a"))
           (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 (cadr 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 (cadr tan)) -1. 1.)
                             (distance pt cCen) (distance pt pertan)))
               (princ (strcat "\n<< Calculated Torque: " (rtos torq 2 4) " >>\n"))
               (write-line (rtos torq 2  ofile)
               (close 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))))
           (princ "\nSelect Curve: "))
         (setq flag T))
       (redraw)))
   (princ "\n<!> Incorrect Selection <!>"))
 (command "_regenall")
 (mapcar 'setvar vlst ovar)
 (princ))

(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))))

 

** We will get this sorted ! **

 

PS> Would you like the lines that are created upon mouse-click to be on a new layer so they can be easily deleted later?

Link to comment
Share on other sites

Also, would you like the program to keep a running total of the calculated torques, so that a net torque can be displayed (and written to file) upon the user exiting the program?

Link to comment
Share on other sites

I'm having a lot of trouble starting the vec.lsp program. The problem may be in my AutoCAD because when typing _appload it asks me for a configuration file which is missing. I overcome this by Esc and can get into _appload but I can only run your latest code if I start an earlier version of it.

 

The signs. They seem to be correct for the torques numbers on the left-hand side. However, the lower torques on the left-hand side still have the torque vectors reversed. The right hand side signs are still not right and all the torque vectors appear reversed.

 

Ultimately, yes, that'sll be very nice -- to have the net torques for each position saved into a special file. We'll have to sort out the sign isuue though. The layers issue -- I like the way you've drawn the curve now. Will have to try it. That may ba a solution.

 

Now, take a look what I did today. This is a plot of the net torques at positions of the wheel of one degree difference (see attached). You can imagine what busy work that is. Your code helped immensely, though.

net_torque_results.GIF

Link to comment
Share on other sites

The 30 degree has to be redone due to problems with the program, that's why it isn't there. Will have to try it with your curve but we'll have to fix the code to make it even more user friendly, aside from the sign issue.

 

I was wondering why shouldn't the Excel files be xls?

 

Also, maybe it won't be bad to have the values on the screen placed automatically at pre-chosen places, to save these many additional clicks when one has to handle so much data.

Link to comment
Share on other sites

I can see how tedious that would be! Having to work out eight torque measurements from scratch, and perform these same eight calculations for every degree of movement!...

 

As for the loading of the program - I am not sure what is happening with the appload, but I would restart AutoCAD and load the program from scratch. If that still doesn't work, try putting in the ACADDOC.lsp (see earlier post), then it will automatically be loaded when you start AutoCAD.

 

As for the signs, I am at a loss - I thought I followed your posted diagram correctly, and got the directions and signs of the torques to be correct. Are you sure you are using the latest posted version?? You mention that you have to load an old version - I wouldn't recommend this as all the versions have the same syntax.

 

My recommendation would be to restart AutoCAD and load the latest version - and if it is still incorrect, I shall have another look if I have time.

 

As for the layers and net torque, these can be easily incorporated, and I shall post a new revision with these elements added.

 

I shall slightly change the syntax in the new revision, so that it has no chance of clashing with other versions.

 

Lee

Link to comment
Share on other sites

I was wondering why shouldn't the Excel files be xls?

 

Its a lot easier to write to a CSV file - a form of Excel file - otherwise you have to go through a COM interface I believe which is a bit of a palava.

 

Also, maybe it won't be bad to have the values on the screen placed automatically at pre-chosen places, to save these many additional clicks when one has to handle so much data.

 

This would take out the lovely animation that you have when selecting a point, but then I suppose I could incorporate both ideas.

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...