;;; SmartBH Native Standalone v3.2 POINTFIX
;;; Rebuilt from supplied DXF.
;;; No external DWG/DXF and no temporary DXF import.
;;; Fixes AutoLISP point-group formatting and safely closes failed block definitions.
(vl-load-com)

(setq *sbh:block-open* nil)

(defun sbh:safe-close-block ()
  (if *sbh:block-open*
    (progn
      (vl-catch-all-apply
        'entmake
        (list '((0 . "ENDBLK")
                (100 . "AcDbEntity")
                (8 . "0")
                (100 . "AcDbBlockEnd"))))
      (setq *sbh:block-open* nil))))

(defun sbh:close-any-stray-block ()
  ;; Repairs an unfinished BLOCK left behind by an older failed SmartBH version.
  (vl-catch-all-apply
    'entmake
    (list '((0 . "ENDBLK")
            (100 . "AcDbEntity")
            (8 . "0")
            (100 . "AcDbBlockEnd"))))
  (setq *sbh:block-open* nil))

(defun sbh:ensure-defpoints ()
  (if (not (tblsearch "LAYER" "DEFPOINTS"))
    (entmake
      '((0 . "LAYER")
        (100 . "AcDbSymbolTableRecord")
        (100 . "AcDbLayerTableRecord")
        (2 . "DEFPOINTS")
        (70 . 0)
        (62 . 7)
        (6 . "Continuous")
        (290 . 0)))))

(defun sbh:build-SBH1_REGULAR ()
  (if (not (tblsearch "BLOCK" "FEBEX_SBH1_REGULAR_V32"))
    (progn
      (sbh:ensure-defpoints)
      (if (not (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockBegin") (2 . "FEBEX_SBH1_REGULAR_V32") (70 . 0) (10 0.0 0.0 0.0))))
        (error "Could not start SmartBH block definition.")
      )
      (setq *sbh:block-open* T)
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 2) (92 . 7) (72 . 1) (73 . 1) (93 . 3) (10 1.294700959615094 0.0 0.0) (42 . 0.4142135623730951) (10 0.0 1.294700959615094 0.0) (42 . 0.0) (10 0.0 0.0 0.0) (42 . 0.0) (97 . 0) (92 . 7) (72 . 1) (73 . 1) (93 . 3) (10 0.0 0.0 0.0) (42 . 0.0) (10 -1.294700959615094 0.0 0.0) (42 . 0.4142135623730951) (10 0.0 -1.294700959615094 0.0) (42 . 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbPolyline") (90 . 2) (70 . 0) (10 -1.29470095958095 0.0 0.0) (10 1.29470095958095 0.0 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . -1) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 2.08628453745041)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . -1) (100 . "AcDbPolyline") (90 . 2) (70 . 0) (10 0.0 1.294700959697365 0.0) (10 0.0 -1.294700959697365 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 2.08628453745041)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbPolyline") (90 . 2) (70 . 0) (10 0.0 1.294700959697365 0.0) (10 0.0 -1.294700959697365 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16711422) (370 . -1) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 1) (72 . 2) (10 0.0 0.0 0.0) (40 . 2.08628453745041) (50 . 0.0) (51 . 360.0) (73 . 1) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . -1) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 1.786284537409352)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . -1) (100 . "AcDbPolyline") (90 . 2) (70 . 0) (10 -1.29470095958095 0.0 0.0) (10 1.29470095958095 0.0 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . -1) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 2) (92 . 7) (72 . 1) (73 . 1) (93 . 3) (10 1.294700959615094 0.0 0.0) (42 . 0.4142135623730951) (10 0.0 1.294700959615094 0.0) (42 . 0.0) (10 0.0 0.0 0.0) (42 . 0.0) (97 . 0) (92 . 7) (72 . 1) (73 . 1) (93 . 3) (10 0.0 0.0 0.0) (42 . 0.0) (10 -1.294700959615094 0.0 0.0) (42 . 0.4142135623730951) (10 0.0 -1.294700959615094 0.0) (42 . 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 1.294700959615094)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "TEXT") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbText") (10 0.0 3.381372911855579 0.0) (40 . 2.25) (1 . "MW2") (41 . 0.75) (72 . 1) (11 0.0 3.381372911855579 0.0) (100 . "AcDbText") (73 . 2)))) (error "Failed creating TEXT entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16777215) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 4) (72 . 1) (10 -3.0 5.036085457541048 0.0) (11 2.999999999999999 5.036085457541048 0.0) (72 . 1) (10 2.999999999999999 5.036085457541048 0.0) (11 2.999999999999999 1.751125345006585 0.0) (72 . 1) (10 2.999999999999999 1.751125345006585 0.0) (11 -3.0 1.751125345006585 0.0) (72 . 1) (10 -3.0 1.751125345006585 0.0) (11 -3.0 5.036085457541048 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (10 -3.0 5.036085457541048 0.0) (10 2.999999999999999 5.036085457541048 0.0) (10 2.999999999999999 1.751125345006585 0.0) (10 -3.0 1.751125345006585 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . -1) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 1.294700959615094)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 1.786284537409352)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "ENDBLK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockEnd"))))
        (error "Could not close SmartBH block definition.")
      )
      (setq *sbh:block-open* nil)
    )
  )
  "FEBEX_SBH1_REGULAR_V32")

(defun sbh:build-SBH1_SOLID ()
  (if (not (tblsearch "BLOCK" "FEBEX_SBH1_SOLID_V32"))
    (progn
      (sbh:ensure-defpoints)
      (if (not (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockBegin") (2 . "FEBEX_SBH1_SOLID_V32") (70 . 0) (10 0.0 0.0 0.0))))
        (error "Could not start SmartBH block definition.")
      )
      (setq *sbh:block-open* T)
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16777215) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 4) (72 . 1) (10 -3.0 5.036085457541048 0.0) (11 2.999999999999999 5.036085457541048 0.0) (72 . 1) (10 2.999999999999999 5.036085457541048 0.0) (11 2.999999999999999 1.751125345006585 0.0) (72 . 1) (10 2.999999999999999 1.751125345006585 0.0) (11 -3.0 1.751125345006585 0.0) (72 . 1) (10 -3.0 1.751125345006585 0.0) (11 -3.0 5.036085457541048 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "TEXT") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbText") (10 0.0 3.381372911855579 0.0) (40 . 2.25) (1 . "MW2") (41 . 0.75) (72 . 1) (11 0.0 3.381372911855579 0.0) (100 . "AcDbText") (73 . 2)))) (error "Failed creating TEXT entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 1.294700959615094)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 2.08628453745041)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . -1) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 1.786284537409352)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16711422) (370 . -1) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 1) (72 . 2) (10 0.0 0.0 0.0) (40 . 2.08628453745041) (50 . 0.0) (51 . 360.0) (73 . 1) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (10 -3.0 5.036085457541048 0.0) (10 2.999999999999999 5.036085457541048 0.0) (10 2.999999999999999 1.751125345006585 0.0) (10 -3.0 1.751125345006585 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 1.786284537409352)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . -1) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 1.294700959615094)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 1) (72 . 2) (10 0.0 0.0 0.0) (40 . 1.294700959615094) (50 . 0.0) (51 . 360.0) (73 . 1) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . -1) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 2.08628453745041)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "ENDBLK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockEnd"))))
        (error "Could not close SmartBH block definition.")
      )
      (setq *sbh:block-open* nil)
    )
  )
  "FEBEX_SBH1_SOLID_V32")

(defun sbh:build-SBH2_REGULAR ()
  (if (not (tblsearch "BLOCK" "FEBEX_SBH2_REGULAR_V32"))
    (progn
      (sbh:ensure-defpoints)
      (if (not (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockBegin") (2 . "FEBEX_SBH2_REGULAR_V32") (70 . 0) (10 0.0 0.0 0.0))))
        (error "Could not start SmartBH block definition.")
      )
      (setq *sbh:block-open* T)
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16777215) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 4) (72 . 1) (10 -3.0 5.036085457541048 0.0) (11 3.0 5.036085457541048 0.0) (72 . 1) (10 3.0 5.036085457541048 0.0) (11 3.0 1.751125345006585 0.0) (72 . 1) (10 3.0 1.751125345006585 0.0) (11 -3.0 1.751125345006585 0.0) (72 . 1) (10 -3.0 1.751125345006585 0.0) (11 -3.0 5.036085457541048 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 1.553641151538112)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . -1) (100 . "AcDbPolyline") (90 . 2) (70 . 0) (10 0.0 1.553641151636838 0.0) (10 0.0 -1.553641151636838 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16711422) (370 . -1) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 1) (72 . 2) (10 0.0 0.0 0.0) (40 . 2.08628453745041) (50 . 0.0) (51 . 360.0) (73 . 1) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 2) (92 . 7) (72 . 1) (73 . 1) (93 . 3) (10 1.553641151538112 0.0 0.0) (42 . 0.4142135623730951) (10 0.0 1.553641151538112 0.0) (42 . 0.0) (10 0.0 0.0 0.0) (42 . 0.0) (97 . 0) (92 . 7) (72 . 1) (73 . 1) (93 . 3) (10 0.0 0.0 0.0) (42 . 0.0) (10 -1.553641151538112 0.0 0.0) (42 . 0.4142135623730951) (10 0.0 -1.553641151538112 0.0) (42 . 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . -1) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 1.553641151538112)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbPolyline") (90 . 2) (70 . 0) (10 0.0 1.553641151636838 0.0) (10 0.0 -1.553641151636838 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . -1) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 2.08628453745041)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . -1) (100 . "AcDbPolyline") (90 . 2) (70 . 0) (10 -1.55364115149714 0.0 0.0) (10 1.55364115149714 0.0 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (10 -3.0 5.036085457541048 0.0) (10 3.0 5.036085457541048 0.0) (10 3.0 1.751125345006585 0.0) (10 -3.0 1.751125345006585 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbPolyline") (90 . 2) (70 . 0) (10 -1.55364115149714 0.0 0.0) (10 1.55364115149714 0.0 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 2.08628453745041)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . -1) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 2) (92 . 7) (72 . 1) (73 . 1) (93 . 3) (10 1.553641151538112 0.0 0.0) (42 . 0.4142135623730951) (10 0.0 1.553641151538112 0.0) (42 . 0.0) (10 0.0 0.0 0.0) (42 . 0.0) (97 . 0) (92 . 7) (72 . 1) (73 . 1) (93 . 3) (10 0.0 0.0 0.0) (42 . 0.0) (10 -1.553641151538112 0.0 0.0) (42 . 0.4142135623730951) (10 0.0 -1.553641151538112 0.0) (42 . 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "TEXT") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbText") (10 0.0 3.381372911855579 0.0) (40 . 2.25) (1 . "BH2") (41 . 0.75) (72 . 1) (11 0.0 3.381372911855579 0.0) (100 . "AcDbText") (73 . 2)))) (error "Failed creating TEXT entity."))
      (if (not (entmake '((0 . "ENDBLK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockEnd"))))
        (error "Could not close SmartBH block definition.")
      )
      (setq *sbh:block-open* nil)
    )
  )
  "FEBEX_SBH2_REGULAR_V32")

(defun sbh:build-SBH2_SOLID ()
  (if (not (tblsearch "BLOCK" "FEBEX_SBH2_SOLID_V32"))
    (progn
      (sbh:ensure-defpoints)
      (if (not (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockBegin") (2 . "FEBEX_SBH2_SOLID_V32") (70 . 0) (10 0.0 0.0 0.0))))
        (error "Could not start SmartBH block definition.")
      )
      (setq *sbh:block-open* T)
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 1.553641151538112)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 7) (72 . 1) (73 . 1) (93 . 2) (10 1.553641151538112 0.0 0.0) (42 . 1.0) (10 -1.553641151538112 0.0 0.0) (42 . 1.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 2.08628453745041)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . -1) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 2.08628453745041)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16711422) (370 . -1) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 1) (72 . 2) (10 0.0 0.0 0.0) (40 . 2.08628453745041) (50 . 0.0) (51 . 360.0) (73 . 1) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "TEXT") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbText") (10 0.0 3.381372911855579 0.0) (40 . 2.25) (1 . "BH2") (41 . 0.75) (72 . 1) (11 0.0 3.381372911855579 0.0) (100 . "AcDbText") (73 . 2)))) (error "Failed creating TEXT entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (10 -3.0 5.036085457541048 0.0) (10 3.0 5.036085457541048 0.0) (10 3.0 1.751125345006585 0.0) (10 -3.0 1.751125345006585 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16777215) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 4) (72 . 1) (10 -3.0 5.036085457541048 0.0) (11 3.0 5.036085457541048 0.0) (72 . 1) (10 3.0 5.036085457541048 0.0) (11 3.0 1.751125345006585 0.0) (72 . 1) (10 3.0 1.751125345006585 0.0) (11 -3.0 1.751125345006585 0.0) (72 . 1) (10 -3.0 1.751125345006585 0.0) (11 -3.0 5.036085457541048 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "ENDBLK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockEnd"))))
        (error "Could not close SmartBH block definition.")
      )
      (setq *sbh:block-open* nil)
    )
  )
  "FEBEX_SBH2_SOLID_V32")

(defun sbh:build-SBH3_SQUARE ()
  (if (not (tblsearch "BLOCK" "FEBEX_SBH3_SQUARE_V32"))
    (progn
      (sbh:ensure-defpoints)
      (if (not (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockBegin") (2 . "FEBEX_SBH3_SQUARE_V32") (70 . 0) (10 0.0 0.0 0.0))))
        (error "Could not start SmartBH block definition.")
      )
      (setq *sbh:block-open* T)
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (10 -1.786651968312403 1.75112534491237 0.0) (10 -1.78665196833572 -1.821443729812119 0.0) (10 1.785917106467602 -1.821443729929649 0.0) (10 1.785917106490916 1.751125344889055 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16711422) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 4) (72 . 1) (10 -1.786651968312403 1.75112534491237 0.0) (11 -1.78665196833572 -1.821443729812119 0.0) (72 . 1) (10 -1.78665196833572 -1.821443729812119 0.0) (11 1.785917106467602 -1.821443729929649 0.0) (72 . 1) (10 1.785917106467602 -1.821443729929649 0.0) (11 1.785917106490916 1.751125344889055 0.0) (72 . 1) (10 1.785917106490916 1.751125344889055 0.0) (11 -1.786651968312403 1.75112534491237 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbPolyline") (90 . 5) (70 . 1) (10 -1.203380108231145 1.167853484886947 0.0) (10 -1.203380108246848 -1.238171869746242 0.0) (10 1.202645246386341 -1.238171869825395 0.0) (10 1.202645246402044 1.167853484807793 0.0) (10 -1.203380108231145 1.167853484823495 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16777215) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 4) (72 . 1) (10 -3.0 5.036085457541048 0.0) (11 2.999999999999999 5.036085457541048 0.0) (72 . 1) (10 2.999999999999999 5.036085457541048 0.0) (11 2.999999999999999 1.751125345006585 0.0) (72 . 1) (10 2.999999999999999 1.751125345006585 0.0) (11 -3.0 1.751125345006585 0.0) (72 . 1) (10 -3.0 1.751125345006585 0.0) (11 -3.0 5.036085457541048 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (10 -3.0 5.036085457541048 0.0) (10 2.999999999999999 5.036085457541048 0.0) (10 2.999999999999999 1.751125345006585 0.0) (10 -3.0 1.751125345006585 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 4) (72 . 1) (10 -1.203380108231145 1.167853484886947 0.0) (11 -1.203380108246848 -1.238171869746242 0.0) (72 . 1) (10 -1.203380108246848 -1.238171869746242 0.0) (11 1.202645246386341 -1.238171869825395 0.0) (72 . 1) (10 1.202645246386341 -1.238171869825395 0.0) (11 1.202645246402044 1.167853484807793 0.0) (72 . 1) (10 1.202645246402044 1.167853484807793 0.0) (11 -1.203380108231145 1.167853484823495 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "TEXT") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbText") (10 0.0 3.381372911855579 0.0) (40 . 2.25) (1 . "MW2") (41 . 0.75) (72 . 1) (11 0.0 3.381372911855579 0.0) (100 . "AcDbText") (73 . 2)))) (error "Failed creating TEXT entity."))
      (if (not (entmake '((0 . "ENDBLK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockEnd"))))
        (error "Could not close SmartBH block definition.")
      )
      (setq *sbh:block-open* nil)
    )
  )
  "FEBEX_SBH3_SQUARE_V32")

(defun sbh:build-SBH3_BOX ()
  (if (not (tblsearch "BLOCK" "FEBEX_SBH3_BOX_V32"))
    (progn
      (sbh:ensure-defpoints)
      (if (not (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockBegin") (2 . "FEBEX_SBH3_BOX_V32") (70 . 0) (10 0.0 0.0 0.0))))
        (error "Could not start SmartBH block definition.")
      )
      (setq *sbh:block-open* T)
      (if (not (entmake '((0 . "TEXT") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbText") (10 0.0 3.381372911855579 0.0) (40 . 2.25) (1 . "MW2") (41 . 0.75) (72 . 1) (11 0.0 3.381372911855579 0.0) (100 . "AcDbText") (73 . 2)))) (error "Failed creating TEXT entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16777215) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 4) (72 . 1) (10 -3.0 5.036085457541048 0.0) (11 2.999999999999999 5.036085457541048 0.0) (72 . 1) (10 2.999999999999999 5.036085457541048 0.0) (11 2.999999999999999 1.751125345006585 0.0) (72 . 1) (10 2.999999999999999 1.751125345006585 0.0) (11 -3.0 1.751125345006585 0.0) (72 . 1) (10 -3.0 1.751125345006585 0.0) (11 -3.0 5.036085457541048 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (10 -3.0 5.036085457541048 0.0) (10 2.999999999999999 5.036085457541048 0.0) (10 2.999999999999999 1.751125345006585 0.0) (10 -3.0 1.751125345006585 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (10 -1.787284057605914 1.786284537397457 0.0) (10 -1.787284057629229 -1.786284537327031 0.0) (10 1.785285017174091 -1.786284537444561 0.0) (10 1.785285017197406 1.786284537374142 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16711422) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 4) (72 . 1) (10 -1.787284057605914 1.786284537397457 0.0) (11 -1.787284057629229 -1.786284537327031 0.0) (72 . 1) (10 -1.787284057629229 -1.786284537327031 0.0) (11 1.785285017174091 -1.786284537444561 0.0) (72 . 1) (10 1.785285017174091 -1.786284537444561 0.0) (11 1.785285017197406 1.786284537374142 0.0) (72 . 1) (10 1.785285017197406 1.786284537374142 0.0) (11 -1.787284057605914 1.786284537397457 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (10 -1.454012197523022 1.453012677310214 0.0) (10 -1.45401219754199 -1.453012677252929 0.0) (10 1.452013157091201 -1.453012677348531 0.0) (10 1.452013157110163 1.453012677291249 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (10 0.7480009595798496 0.7480009596973665 0.0) (10 -0.7500000000010996 0.7480009596973665 0.0) (10 -0.7500000000010996 -0.7480009596973654 0.0) (10 0.7480009595798496 -0.7480009596973654 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 2) (92 . 16) (93 . 4) (72 . 1) (10 0.7480009595798496 0.7480009596973665 0.0) (11 -0.7500000000010996 0.7480009596973665 0.0) (72 . 1) (10 -0.7500000000010996 0.7480009596973665 0.0) (11 -0.7500000000010996 -0.7480009596973652 0.0) (72 . 1) (10 -0.7500000000010996 -0.7480009596973654 0.0) (11 0.7480009595798496 -0.7480009596973654 0.0) (72 . 1) (10 0.7480009595798496 -0.7480009596973654 0.0) (11 0.7480009595798496 0.7480009596973664 0.0) (97 . 0) (92 . 1) (93 . 4) (72 . 1) (10 -1.454012197523022 1.453012677310214 0.0) (11 -1.45401219754199 -1.453012677252929 0.0) (72 . 1) (10 -1.45401219754199 -1.453012677252929 0.0) (11 1.452013157091201 -1.453012677348531 0.0) (72 . 1) (10 1.452013157091201 -1.453012677348531 0.0) (11 1.452013157110163 1.453012677291249 0.0) (72 . 1) (10 1.452013157110163 1.453012677291249 0.0) (11 -1.454012197523022 1.453012677310214 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "ENDBLK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockEnd"))))
        (error "Could not close SmartBH block definition.")
      )
      (setq *sbh:block-open* nil)
    )
  )
  "FEBEX_SBH3_BOX_V32")

(defun sbh:build-SBH3_TRIANGLE ()
  (if (not (tblsearch "BLOCK" "FEBEX_SBH3_TRIANGLE_V32"))
    (progn
      (sbh:ensure-defpoints)
      (if (not (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockBegin") (2 . "FEBEX_SBH3_TRIANGLE_V32") (70 . 0) (10 0.0 0.0 0.0))))
        (error "Could not start SmartBH block definition.")
      )
      (setq *sbh:block-open* T)
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbPolyline") (90 . 3) (70 . 1) (10 0.0 2.071521535515785 0.0) (10 -1.793990274243217 -1.035760767757891 0.0) (10 1.793990274243218 -1.035760767757893 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "TEXT") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbText") (10 0.0 3.381372911855579 0.0) (40 . 2.25) (1 . "MW2") (41 . 0.75) (72 . 1) (11 0.0 3.381372911855579 0.0) (100 . "AcDbText") (73 . 2)))) (error "Failed creating TEXT entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16711422) (370 . -1) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 2) (92 . 7) (72 . 0) (73 . 1) (93 . 3) (10 0.0 2.671521535515788 0.0) (10 -2.313605516513883 -1.335760767757893 0.0) (10 2.313605516513884 -1.335760767757894 0.0) (97 . 0) (92 . 22) (72 . 0) (73 . 1) (93 . 3) (10 1.793990274243218 -1.035760767757893 0.0) (10 -1.793990274243217 -1.035760767757891 0.0) (10 0.0 2.071521535515785 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbPolyline") (90 . 3) (70 . 1) (10 0.0 2.671521535515788 0.0) (10 -2.313605516513882 -1.335760767757893 0.0) (10 2.313605516513884 -1.335760767757895 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 7) (72 . 0) (73 . 1) (93 . 3) (10 0.0 2.071521535515785 0.0) (10 -1.793990274243216 -1.035760767757891 0.0) (10 1.793990274243218 -1.035760767757893 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (10 -3.0 5.036085457541048 0.0) (10 2.999999999999999 5.036085457541048 0.0) (10 2.999999999999999 1.751125345006585 0.0) (10 -3.0 1.751125345006585 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16777215) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 4) (72 . 1) (10 -3.0 5.036085457541048 0.0) (11 2.999999999999999 5.036085457541048 0.0) (72 . 1) (10 2.999999999999999 5.036085457541048 0.0) (11 2.999999999999999 1.751125345006585 0.0) (72 . 1) (10 2.999999999999999 1.751125345006585 0.0) (11 -3.0 1.751125345006585 0.0) (72 . 1) (10 -3.0 1.751125345006585 0.0) (11 -3.0 5.036085457541048 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "ENDBLK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockEnd"))))
        (error "Could not close SmartBH block definition.")
      )
      (setq *sbh:block-open* nil)
    )
  )
  "FEBEX_SBH3_TRIANGLE_V32")

(defun sbh:build-SBH3_DONUT ()
  (if (not (tblsearch "BLOCK" "FEBEX_SBH3_DONUT_V32"))
    (progn
      (sbh:ensure-defpoints)
      (if (not (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockBegin") (2 . "FEBEX_SBH3_DONUT_V32") (70 . 0) (10 0.0 0.0 0.0))))
        (error "Could not start SmartBH block definition.")
      )
      (setq *sbh:block-open* T)
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16777215) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 4) (72 . 1) (10 -3.0 5.036085457541048 0.0) (11 2.999999999999999 5.036085457541048 0.0) (72 . 1) (10 2.999999999999999 5.036085457541048 0.0) (11 2.999999999999999 1.751125345006585 0.0) (72 . 1) (10 2.999999999999999 1.751125345006585 0.0) (11 -3.0 1.751125345006585 0.0) (72 . 1) (10 -3.0 1.751125345006585 0.0) (11 -3.0 5.036085457541048 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (10 -3.0 5.036085457541048 0.0) (10 2.999999999999999 5.036085457541048 0.0) (10 2.999999999999999 1.751125345006585 0.0) (10 -3.0 1.751125345006585 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "TEXT") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbText") (10 0.0 3.381372911855579 0.0) (40 . 2.25) (1 . "MW2") (41 . 0.75) (72 . 1) (11 0.0 3.381372911855579 0.0) (100 . "AcDbText") (73 . 2)))) (error "Failed creating TEXT entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 1.0)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16711422) (370 . -1) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 3) (92 . 1) (93 . 1) (72 . 2) (10 0.0 0.0 0.0) (40 . 2.08628453745041) (50 . 0.0) (51 . 360.0) (73 . 1) (97 . 0) (92 . 17) (93 . 1) (72 . 2) (10 0.0 0.0 0.0) (40 . 1.75) (50 . 0.0) (51 . 360.0) (73 . 1) (97 . 0) (92 . 16) (93 . 1) (72 . 2) (10 0.0 0.0 0.0) (40 . 1.0) (50 . 0.0) (51 . 360.0) (73 . 1) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 2.08628453745041)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 2) (92 . 7) (72 . 1) (73 . 1) (93 . 2) (10 -1.75 0.0 0.0) (42 . 1.0) (10 1.75 0.0 0.0) (42 . 1.0) (97 . 0) (92 . 22) (72 . 1) (73 . 1) (93 . 2) (10 1.0 0.0 0.0) (42 . -1.0) (10 -1.0 0.0 0.0) (42 . -1.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbCircle") (10 0.0 0.0 0.0) (40 . 1.75)))) (error "Failed creating CIRCLE entity."))
      (if (not (entmake '((0 . "ENDBLK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockEnd"))))
        (error "Could not close SmartBH block definition.")
      )
      (setq *sbh:block-open* nil)
    )
  )
  "FEBEX_SBH3_DONUT_V32")

(defun sbh:build-SBH3_DIAMOND ()
  (if (not (tblsearch "BLOCK" "FEBEX_SBH3_DIAMOND_V32"))
    (progn
      (sbh:ensure-defpoints)
      (if (not (entmake '((0 . "BLOCK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockBegin") (2 . "FEBEX_SBH3_DIAMOND_V32") (70 . 0) (10 0.0 0.0 0.0))))
        (error "Could not start SmartBH block definition.")
      )
      (setq *sbh:block-open* T)
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (10 -3.0 5.036085457541048 0.0) (10 2.999999999999999 5.036085457541048 0.0) (10 2.999999999999999 1.751125345006585 0.0) (10 -3.0 1.751125345006585 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16777215) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 4) (72 . 1) (10 -3.0 5.036085457541048 0.0) (11 2.999999999999999 5.036085457541048 0.0) (72 . 1) (10 2.999999999999999 5.036085457541048 0.0) (11 2.999999999999999 1.751125345006585 0.0) (72 . 1) (10 2.999999999999999 1.751125345006585 0.0) (11 -3.0 1.751125345006585 0.0) (72 . 1) (10 -3.0 1.751125345006585 0.0) (11 -3.0 5.036085457541048 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "TEXT") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbText") (10 0.0 3.381372911855579 0.0) (40 . 2.25) (1 . "MW2") (41 . 0.75) (72 . 1) (11 0.0 3.381372911855579 0.0) (100 . "AcDbText") (73 . 2)))) (error "Failed creating TEXT entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbPolyline") (90 . 5) (70 . 1) (10 5.1728e-12 1.553641151553425 0.0) (10 -1.553641151491968 1.53125e-11 0.0) (10 5.1728e-12 -1.5536411515228 0.0) (10 1.553641151502313 1.53125e-11 0.0) (10 -3.57989e-11 1.553641151512453 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 7) (420 . 16711422) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 4) (72 . 1) (10 -4.57305e-11 2.306912651835895 0.0) (11 -2.306912651805475 1.53126e-11 0.0) (72 . 1) (10 -2.306912651805475 1.53128e-11 0.0) (11 5.1728e-12 -2.306912651856174 0.0) (72 . 1) (10 5.1728e-12 -2.306912651856174 0.0) (11 2.306912651825754 2.52451e-11 0.0) (72 . 1) (10 2.306912651825754 2.52453e-11 0.0) (11 -4.57305e-11 2.306912651835895 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "DEFPOINTS") (62 . 8) (370 . 9) (100 . "AcDbPolyline") (90 . 4) (70 . 1) (10 -4.57305e-11 2.306912651835895 0.0) (10 -2.306912651805475 1.53128e-11 0.0) (10 5.1728e-12 -2.306912651856174 0.0) (10 2.306912651825754 2.52453e-11 0.0)))) (error "Failed creating LWPOLYLINE entity."))
      (if (not (entmake '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (62 . 0) (370 . 9) (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 1) (93 . 4) (72 . 1) (10 5.1728e-12 1.553641151553425 0.0) (11 -1.553641151491968 1.53126e-11 0.0) (72 . 1) (10 -1.553641151491968 1.53125e-11 0.0) (11 5.1728e-12 -1.5536411515228 0.0) (72 . 1) (10 5.1728e-12 -1.5536411515228 0.0) (11 1.553641151502313 1.53126e-11 0.0) (72 . 1) (10 1.553641151502313 1.53125e-11 0.0) (11 -3.57989e-11 1.553641151512453 0.0) (97 . 0) (75 . 0) (76 . 1) (98 . 1) (10 0.0 0.0 0.0)))) (error "Failed creating HATCH entity."))
      (if (not (entmake '((0 . "ENDBLK") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbBlockEnd"))))
        (error "Could not close SmartBH block definition.")
      )
      (setq *sbh:block-open* nil)
    )
  )
  "FEBEX_SBH3_DIAMOND_V32")

(setq *sbh:states-v32* (list
  (list "SBH1_REGULAR" "Smart Block 1 - Regular" 'sbh:build-SBH1_REGULAR)
  (list "SBH1_SOLID" "Smart Block 1 - Solid" 'sbh:build-SBH1_SOLID)
  (list "SBH2_REGULAR" "Smart Block 2 - Regular" 'sbh:build-SBH2_REGULAR)
  (list "SBH2_SOLID" "Smart Block 2 - Solid" 'sbh:build-SBH2_SOLID)
  (list "SBH3_SQUARE" "Smart Block 3 - Square" 'sbh:build-SBH3_SQUARE)
  (list "SBH3_BOX" "Smart Block 3 - Box" 'sbh:build-SBH3_BOX)
  (list "SBH3_TRIANGLE" "Smart Block 3 - Triangle" 'sbh:build-SBH3_TRIANGLE)
  (list "SBH3_DONUT" "Smart Block 3 - Dohugnut" 'sbh:build-SBH3_DONUT)
  (list "SBH3_DIAMOND" "Smart Block 3 - Diamond" 'sbh:build-SBH3_DIAMOND)
))

(defun sbh:set-insert-color (e / d)
  (if e
    (progn
      (setq d (entget e))
      (if (assoc 420 d) (setq d (vl-remove (assoc 420 d) d)))
      (if (assoc 62 d)
        (setq d (subst (cons 62 87) (assoc 62 d) d))
        (setq d (append d (list (cons 62 87)))))
      (entmod d)
      (entupd e))))

(defun sbh:place (state / builder bname p e oldattreq oldcmdecho)
  (setq builder (caddr state))
  (setq bname (eval (list builder)))
  (setq oldattreq (getvar "ATTREQ")
        oldcmdecho (getvar "CMDECHO"))
  (setvar "ATTREQ" 0)
  (setvar "CMDECHO" 0)
  (prompt "\nClick insertion points. Press Enter to finish.")
  (while (setq p (getpoint "\nInsertion point <Enter=Finish>: "))
    (command "_.-INSERT" bname p 1.0 1.0 0.0)
    (setq e (entlast))
    (sbh:set-insert-color e))
  (setvar "ATTREQ" oldattreq)
  (setvar "CMDECHO" oldcmdecho))

(defun c:SBH (/ *error* olderr i n ans state)
  (setq olderr *error*)
  (defun *error* (msg)
    (sbh:safe-close-block)
    (if msg (prompt (strcat "\nSmartBH error: " msg)))
    (setq *error* olderr)
    (princ))
  ;; Close a definition left open by v3.0/v3.1 before doing anything else.
  (sbh:close-any-stray-block)
  (setvar "QTEXTMODE" 0)
  (setvar "FILLMODE" 1)
  (prompt "\nSmartBH Native Standalone v3.2 POINTFIX")
  (setq i 1)
  (foreach s *sbh:states-v32*
    (prompt (strcat "\n  [" (itoa i) "] " (cadr s)))
    (setq i (1+ i)))
  (setq n (length *sbh:states-v32*))
  (setq ans (getint (strcat "\nChoose state [1-" (itoa n) "] <Enter=Cancel>: ")))
  (if (and ans (>= ans 1) (<= ans n))
    (progn
      (setq state (nth (1- ans) *sbh:states-v32*))
      (prompt (strcat "\nSelected: " (cadr state)))
      (sbh:place state)
      (command "_.REGENALL"))
    (prompt "\nCancelled."))
  (setq *error* olderr)
  (princ))

(prompt "\nSmartBH Native Standalone v3.2 POINTFIX loaded. Command: SBH")
(princ)
