Author Topic: Enter associative dimensions with entmake  (Read 1767 times)

0 Members and 1 Guest are viewing this topic.

Lupo76

  • Bull Frog
  • Posts: 343
Enter associative dimensions with entmake
« on: January 26, 2015, 03:18:50 AM »
Hello everyone,
few years ago I found on the web the following code that allows you to insert DIMENSION entities in the drawing :

Code: [Select]
(defun entmakeDimLinear (p1 p2 TXT EBENE STIL LAYER COLOR)
  ;Use: (entmakeDimLinear (getpoint)(getpoint) "TEST" '(0.7 . 1) "STANDARD" "0" nil)
  ;EBENE '(ABSTAND . POSITIONSEBENE) '([REAL] . [INTEGER]) : (7 . 2) ;???????????????

 
  (if (= (length p1) 2)(setq p1 (append p1 (list 0.0)))) ;aggiunge la Z
  (if (= (length p2) 2)(setq p2 (append p2 (list 0.0)))) ;aggiunge la Z
 
  (defun Is3DPoint? (P)
    (and P (= 'LIST (type P))
      (or (= 'REAL (type (car P)))
        (= 'INT (type (car P)))
      )
      (or (= 'REAL (type (cadr P)))
        (= 'INT (type (cadr P)))
      )
      (or (= 'REAL (type (caddr P)))
        (= 'INT (type (caddr P)))
      )
    )
  )
  (if (and
        (Is3DPoint? p1)(Is3DPoint? p2)
        (entmake (list
                  '(0 . "DIMENSION")
                  '(100 . "AcDbEntity")
                  '(67 . 0)
                  '(410 . "Model")
                  (cons 8 (if (and LAYER (= 'STR(type LAYER))(tblobjname "LAYER" LAYER))LAYER (getvar "CLAYER")));sonst CLAYER
                  (cons 62 (if (and COLOR (= 'INT (type COLOR)))COLOR 256));sonst VONLAYER
                  '(100 . "AcDbDimension")
                  (if (and EBENE
                            (= 'LIST (type EBENE))
                            (car EBENE)(or (= 'REAL (type (car EBENE)))(= 'INT (type (car EBENE))))(/= (car EBENE) 0.0)
                            (cdr EBENE)(or (= 'REAL (type (cdr EBENE)))(= 'INT (type (cdr EBENE))))(/= (cdr EBENE) 0.0)
                            )
                    (cons 10 (polar p2 (+ (angle p1 p2) (/ pi 2.0)) (* (car EBENE) (cdr EBENE))))
                    (cons 10 p2)
                    )
                  '(12 0.0 0.0 0.0)
                  '(70 . 33)
                  (cons 1 (if (and TXT (= 'STR(type TXT)))TXT ""))
                  '(71 . 5)
                  '(72 . 1)
                  '(41 . 1.0)
                  '(73 . 0)
                  '(74 . 0)
                  '(75 . 0)
                  '(52 . 0.0)
                  '(53 . 0.0)
                  '(54 . 0.0)
                  '(51 . 0.0)
                  '(210 0.0 0.0 1.0)
                  (cons 3 (if (and STIL (= 'STR(type STIL))(tblobjname "DIMSTYLE" STIL))STIL (getvar "DIMSTYLE")))
                  '(100 . "AcDbAlignedDimension")
                  (cons 13 p1)
                  (cons 14 p2)
                  '(15 0.0 0.0 0.0)
                  '(16 0.0 0.0 0.0)
                  '(40 . 0.0)
                  '(50 . 0.0)
                  )
        )
      )
      (entlast)
  )
)

Unfortunately this code inserts non-associative dimensions regardless of the value of  DIMASSOC.
Do you have any suggestion to solve this limitation?

Lupo76

  • Bull Frog
  • Posts: 343
Re: Enter associative dimensions with entmake
« Reply #1 on: January 27, 2015, 03:42:38 AM »
To reassociate a dimension I wrote this code:

Code: [Select]
(defun c:test3 ()
  (setq ent1 (car (entsel)))
  (setq vlaobj (vlax-ename->vla-object ent1))
  (setq pp (vlax-get vlaobj 'ExtLine1Point))
  (setq ps (vlax-get vlaobj 'ExtLine2Point))
  (vl-cmdf "_.dimreassociate" ent1 "" pp ps)
)

It works, however I need to implement something like this without using (vl-cmdf) or (command) because I have to put this code in a reactor.

Have you any suggestions?

thanks in advance