Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/22/2022 in all areas

  1. Two points define one line. To find an angle between two lines you need another line stated either explicitly or implicitly. The lisp function angle assume implicitly that the "other" line is the x axis. What assumption would you like to make about the other line if only given two points? A program could output, for example, the angles between the line defined by two points with the world X axis, Y axis and Z axis. It could also output the angle with it projection onto one of the principal planes (e.g., the XY plane) or... What do you need? Be as detailed as possible.
    1 point
  2. I merged your threads since they are pretty much the same.
    1 point
  3. Load "Compare" plugin its really handy use with entget when changing 1 variable and trying to find dxf numbers. Same with setvar. use replace ") (" with ")\r(" when comparing entgets.
    1 point
  4. Here's a program to calculate the angle between two line defined by three points. (defun c:3dangle (/ p1 p2 p3 v1 v2 angrad angdeg) (setq p1 (getpoint "\nPick point common to both lines.") p2 (getpoint p1 "\nPick end of first line.") p3 (getpoint p1 "\nPick end of second line.") v1 (uvec (mapcar '- p2 p1)) v2 (uvec (mapcar '- p3 p1)) angrad (@acos (dot v1 v2)) angdeg (/ (* angrad 180.) 3.14159265359) ) (princ "\nAngle between the two lines (degrees): ") (princ angdeg) (princ) ) ;;------------------------------------------------------ ;; Function to return the arccos of an angle in radians: ;; author unknown (defun @acos (cosine / sine) (cond ((zerop cosine)(* pi 0.5)) ((<= cosine -1.0) pi) ((>= cosine 1.0) 0.0) (1 (atan (/ (sqrt (- 1.0 (expt cosine 2))) cosine))) ) ) ;;------------------------------------------------------ ;;; Compute the dot product of 2 vectors a and b (defun dot (a b / dd) (setq dd (mapcar '* a b)) (setq dd (+ (nth 0 dd) (nth 1 dd) (nth 2 dd))) ) ;end of dot ;;------------------------------------------------------ ; calculate unit vector of vector v1 (defun uvec (v1 / s) (setq s (distance '(0 0 0) v1 )) (setq s (mapcar '/ v1 (list s s s))) )
    1 point
  5. If you’re interested in seeing a previous version of AutoCAD, I posted a video demonstrating the new features in AutoCAD version 2.01:
    1 point
  6. Try the following: (defun c:fixatts ( / d e i s x ) (while (setq d (tblnext "block" (null d))) (if (= 2 (logand 2 (cdr (assoc 70 d)))) (progn (setq e (tblobjname "block" (cdr (assoc 2 d)))) (while (setq e (entnext e)) (if (and (setq x (entget e)) (= "ATTDEF" (cdr (assoc 0 x))) (= "SIZE" (cdr (assoc 2 x))) ) (entmod (cons (cons -1 e) '((8 . "SYM") (62 . 141)))) ) ) ) ) ) (if (setq s (ssget "_X" '((0 . "INSERT") (66 . 1)))) (repeat (setq i (sslength s)) (setq e (entnext (ssname s (setq i (1- i)))) x (entget e) ) (while (= "ATTRIB" (cdr (assoc 0 x))) (if (= "SIZE" (cdr (assoc 2 x))) (entmod (cons (cons -1 e) '((8 . "SYM") (62 . 141)))) ) (setq e (entnext e) x (entget e) ) ) ) ) (princ) ) The second half of the code could be replaced by a call to ATTSYNC, but bear in mind that such a call would cause the properties of all attributes to revert to those defined in the block definition, which may be undesirable.
    1 point
×
×
  • Create New...