Author Topic: Constructive Critism?  (Read 15061 times)

0 Members and 1 Guest are viewing this topic.

SMadsen

  • Guest
Constructive Critism?
« Reply #15 on: October 29, 2003, 12:45:28 PM »
nivuach,
Ever heard of MAPCAR? :D

.. and nested defun's? (http://theswamp.org/phpBB2/viewtopic.php?t=161)

Code: [Select]
(defun MAKEBS (/ entmakeText entmakeTrace)
  (defun entmakeText (lst / ins hgt txt)
    (mapcar 'set '(ins hgt txt) lst)
    (entmake (append '((0 . "TEXT") (8 . "0")(7 . "Standard"))
                     (list (cons 10 ins) (cons 40 hgt) (cons 1 txt))))
  )
  (defun entmakeTrace (lst / p1 p2 p3 p4)
    (mapcar 'set '(p1 p2 p3 p4) lst)
    (entmake (append '((0 . "TRACE") (8 . "0"))
                     (list (cons 10 p1) (cons 11 p2) (cons 12 p3) (cons 13 p4))))
  )
  (entmake '((0 . "BLOCK") (2 . "BARSCALE") (8 . "0") (70 . 66) (10 0.0 0.0 0.0)))
  (mapcar 'entmakeText
          '(((0.715717 -22.7268 0.0) 12.0 "0")
            ((22.5262 -22.7268 0.0) 12.0 "2'")
            ((48.6081 -22.7268 0.0) 12.0 "4'")
            ((95.9303 -22.7268 0.0) 12.0 "8'")
            ((191.507 -22.7268 0.0) 12.0 "16'")
            ((279.661 -22.7268 0.0) 12.0 "24'")
            ((318.56 0.36234 0.0) 12.0 "SCALE")
           )
  )
  (entmake '((0 . "ATTDEF")(8 . "0")(10 318.56 -19.6377 0.0)(40 . 12.0)(70 . 0) (1 . "")
             (7 . "Standard")(3 . "Scale Factor")(2 . "scale"))
  )
  (mapcar 'entmakeTrace
          '(((291.721 2.06301 0.0)(291.721 11.063 0.0)
             (195.721 2.06301 0.0)(195.721 11.063 0.0))
            ((99.7205 2.06301 0.0)(99.7205 11.063 0.0)
             (51.7205 2.06301 0.0)(51.7205 11.063 0.0))
            ((15.7205 -6.93699 0.0)(15.7205 2.06301 0.0)
             (9.72052 -6.93699 0.0)(9.72052 2.06301 0.0))
            ((9.72052 2.06301 0.0)(9.72052 11.063 0.0)
             (3.72052 2.06301 0.0)(3.72052 11.063 0.0))
            ((27.7205 2.06301 0.0)(27.7205 11.063 0.0)
             (15.7205 2.06301 0.0)(15.7205 11.063 0.0))
            ((51.7205 -6.93699 0.0)(51.7205 2.06301 0.0)
             (27.7205 -6.93699 0.0)(27.7205 2.06301 0.0))
            ((195.721 -6.93699 0.0)(195.721 2.06301 0.0)
             (99.7205 -6.93699 0.0)(99.7205 2.06301 0.0))
           )
  )
  (entmake
    '((0 . "LINE") (8 . "0") (62 . 0) (10 3.72052 3.72864 0.0) (11 3.72052 -6.93699 0.0)))
  (entmake
    '((0 . "LINE") (8 . "0") (62 . 0) (10 291.721 11.063 0.0) (11 291.721 -6.93699 0.0)))
  (entmake '((0 . "ENDBLK")(100 . "AcDbBlockEnd")))
)

daron

  • Guest
Constructive Critism?
« Reply #16 on: October 29, 2003, 02:11:14 PM »
Ahh! I knew there was a way to make entmake stop hurting my eyes. I've avoided entmake in the past because I've only seen people use it the way Chuck did. Stig, that is so much nicer. Great idea. I've wondered also, why entmake is so popular when inserting a block is so much easier. What makes writing all that entmake code so desirable?

SMadsen

  • Guest
Constructive Critism?
« Reply #17 on: October 29, 2003, 03:44:58 PM »
Well, you know those guys and gals that sometimes uses your seat and think that spring cleaning is due every day? They delete what they don't understand .. including company blocks!

Ok, so I guess the main reason is for parametric design. Instead of having 5 barscale blocks predefined in some directory and more or less hardcoded paths in your lisp routines, you could offer a dialog with nice adjustable features.

This was just for fun, though. Judging from the file that nivuach links to in the signature, I'll bet nivuach has written a program that converts a drawing to ENTMAKE calls :)

I would use wblocks any time, also (if no parametric design is needed). But inserting the block I would probably do with ENTMAKE. It's fast, it's clean and it can be tested more easily than a command (unless VL-CMDF is used).

daron

  • Guest
Constructive Critism?
« Reply #18 on: October 30, 2003, 10:33:50 AM »
Moved the race to its own thread. RJP, back to your regularly scheduled program.

nivuahc

  • Guest
Constructive Critism?
« Reply #19 on: October 31, 2003, 09:32:52 AM »
Quote
Ever heard of MAPCAR?  

.. and nested defun's?


C'mon... I threw that together in about 5 minutes!  :shock:

:P

SMadsen

  • Guest
Constructive Critism?
« Reply #20 on: October 31, 2003, 11:00:47 AM »
It was just for fun, nivuahc

Btw, here's a thing that can make entmakes of almost anything pulled from a drawing:
Code: [Select]
(defun C:makeEntmake (/ a dwg path ent entl fn sset)
  (setq path (getvar "DWGPREFIX")
        dwg  (strcat path (vl-filename-base (getvar "DWGNAME")) ".lsp")
        fn   (open dwg "w")
        a    0
  )
  (cond
    (fn
     (cond ((setq sset (ssget))
            (repeat (sslength sset)
              (setq ent  (ssname sset a)
                    entl (entget ent)
              )
              (mapcar (function (lambda (n) (setq entl (vl-remove (assoc n entl) entl))))
                      '(-2 -1 5 102 300 330 331 350 360)
              )
              (write-line (strcat "(entmake '" (vl-prin1-to-string entl) ")") fn)
              (setq a (1+ a))
            )
           )
     )
     (close fn)
    )
  )
  (princ)
)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Constructive Critism?
« Reply #21 on: October 31, 2003, 07:27:19 PM »
Makes my old heart sing.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.