'Nother little routine

Discussion in 'AutoCAD' started by Dr Fleau, May 14, 2007.

  1. Dr Fleau

    Dr Fleau Guest

    All of my routines are geometrical in nature and are basically regular ACAD
    commands with a purpose. Here's a cone-developing thing that was done last
    week. Don't know why I never did this before.

    A little info: the routine lets you pick 2 lines which would be the
    generators of a cone. Please make sure that both lines are the same length
    or you may get funky results. Oh yeah, it's in french, too.

    Copy and share.

    Dr Fléau

    (defun c:conedevelop
    (/ tmp lin1 lin2 p1 p2 p3 p4 p5 ray ang center oldvar)
    (setq lin1 (entsel "Première ligne : ")
    lin2 (entsel "Deuxième ligne :")
    )
    (setq oldvar (getvar "OSMODE"))
    (setvar "OSMODE" 0)
    ;;; Extirpe les 4 points des extrémités
    (setq p1 (cdr (assoc 10 (cdr (entget (car lin1)))))
    p2 (cdr (assoc 11 (cdr (entget (car lin1)))))
    p3 (cdr (assoc 10 (cdr (entget (car lin2)))))
    p4 (cdr (assoc 11 (cdr (entget (car lin2)))))
    )
    ;;; Trouve l'intersection
    (setq p5 (inters p1 p2 p3 p4 nil))
    (if (< (distance p5 p1) (distance p5 p2))
    (setq tmp p1
    p1 p2
    p2 tmp
    )
    )
    (if (< (distance p5 p3) (distance p5 p4))
    (setq tmp p3
    p3 p4
    p4 tmp
    )
    )
    ;;; Calcule la longueur du cone complet
    (setq dis (distance p1 p5))
    ;;; Trouve le rayon de la base du cone
    (setq ray (/ (distance p1 p3) 2.0))
    ;;; Trouve l'angle de la développante
    (setq ang (/ (* 360.0 ray) dis))
    ;;; Donne le point d'insertion
    (setq center (getpoint "Donne le point d'insertion :"))
    (setq temp (polar center (/ pi 2) (- dis (distance p1 p2))))
    ;;; Trace la ligne de départ du développement
    (command "_.line" temp (polar temp (/ pi 2) (distance p1 p2)) "")
    (command "_-array" (entlast) "" "P" center 2 ang "Y")
    (command "_arc" "ce" center (polar temp (/ pi 2) (distance p1 p2)) "A"
    ang)
    (command "_arc" "ce" center (polar center (/ pi 2) (- dis (distance p1
    p2))) "A" ang)
    (setvar "OSMODE" oldvar)
    )
     
    Dr Fleau, May 14, 2007
    #1
  2. Dr Fleau

    Guest Guest

    Using R14. Returns this message:

    Command: conedevelop
    Première ligne : Deuxième ligne :Donne le point d'insertion :int
    of Unknown command "-ARRAY". Press F1 for help.
    <Entity name: 3D80968>
    error: Function cancelled
    (COMMAND "_-array" (ENTLAST) "" "P" CENTER 2 ANG "Y")
    (C:CONEDEVELOP)

    Brian.
     
    Guest, May 14, 2007
    #2
  3. Try switching the hyphen with a period:
    "_.array"
     
    Michael Bulatovich, May 14, 2007
    #3
  4. Dr Fleau

    Guest Guest

    Indeed so. Thank you both for the routine.

    Brian.
     
    Guest, May 14, 2007
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.