Autolisp Code verbessern (Autocad)

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Autolisp Code verbessern (Autocad)

    Source Code

    1. (defun C:dreh(/ x)
    2. (setq time 40)
    3. (command "_UCS" "_w")
    4. (setq xm 1000.0)
    5. (setq ym 500.0)
    6. (command "_.rectang" "975,475" "1025,525")
    7. (setq coor (list
    8. (list 950.0 500.0 )
    9. (list 1050.0 500.0)
    10. (list 1050.0 550.0)
    11. (list 1000.0 550.0)
    12. (list 1000.0 450.0)
    13. (list 950.0 450.0 )
    14. (list 950.0 550.0 )
    15. (list 1050.0 550.0)
    16. (list 1050.0 450.0)
    17. (list 1000.0 450.0)
    18. )
    19. )
    20. (setvar "clayer" "2")
    21. ;;Kann man das besser machen??????
    22. (command "_.pline")
    23. (foreach x coor
    24. (command x)
    25. )
    26. (command "")
    27. (setvar "clayer" "0")
    28. (setq ed (entget(entlast))) ;; grab polyline
    29. (setvar "clayer" "1")
    30. (command "_.rectang" (list xm ym) (list (+ xm 50.0) (+ ym 50.0)) )
    31. (setq big (entget(entlast)))
    32. (setvar "clayer" "0")
    33. (setq winkel (/ (* 1.0 PI) 180.0) )
    34. (setq y 1)
    35. ;;jetzt wird einmal im Kreis rotiert
    36. (while (<= y 360)
    37. (progn
    38. (setq ed (rotate xm ym winkel ed))
    39. (setq big (rotate xm ym winkel big))
    40. (setq small_ed ed)
    41. (setq y (1+ y))
    42. ;(entmod ed)
    43. (command "_delay" time)
    44. )
    45. )
    46. )
    47. (defun rotate (x1 y1 angle1 object)
    48. (setq small_ed object)
    49. (while (/= (assoc 10 small_ed) nil)
    50. (progn
    51. (setq x (cdr(assoc 10 small_ed)))
    52. (setq object (subst (list 10 (+ (* (- (car x) x1) (cos angle1)) (* -1.0 (- (cadr x) y1) (sin angle1)) x1)
    53. (+ (* (- (car x) x1) (sin angle1)) (* (- (cadr x) y1) (cos angle1)) y1)
    54. )
    55. (assoc 10 small_ed )
    56. object ))
    57. (setq small_ed (cdr (member (assoc 10 small_ed) small_ed)) )
    58. )
    59. )
    60. (entmod object)
    61. )
    Display All


    Kann mir vielleicht jemand sagen wie ich meine Code verbessern könnte. Ich selber finde ihn nicht besonders schön, weiß aber auch nicht wie ich ihn verbessern könnte.
    Lg Apfelstrudl

    Ps.: Der Code erzeugt genau das:
    [Blocked Image: http://farm3.static.flickr.com/2484/3612225246_813c7f5a63_o.gif]

    The post was edited 1 time, last by Apfelstrudl ().