Author Topic: Modify arrowhead size in a leader  (Read 5049 times)

0 Members and 1 Guest are viewing this topic.

septicad

  • Guest
Modify arrowhead size in a leader
« on: March 27, 2008, 10:33:47 AM »
How do you modify the arrowhead size of an existing leader or dimension with LISP or VLISP?

The leaders/dimensions were originally created with the current dimStyle and overrides set via the DIMASZ and DIMTXT system variables.  The DIMSCALE variable is always set to 1 because the arrowhead size and text size can be set independently via a "custom user preferences menu".

The idea is: if someone wants to change the drawing scale - then a simple function will modify the vports [known] + also allow the user to select the dims/leaders/mText/text entities and modify the sizes accordingly.  (i.e. if i change from 1:10 to 1:20, I need to change all the text heights from 1 to 2 [known] + also change the arrowhead sizes [not known])


Thanks in advance

Steve

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Modify arrowhead size in a leader
« Reply #1 on: March 27, 2008, 11:25:06 AM »
To change the leader scale you would need to change the xdata.
Code: [Select]
Command: getxdata
Initializing...
Select object to get dictionary.
(-3 ("ACAD" (1000 . "DSTYLE")
    (1002 . "{")
       (1070 . 41) (1040 . 9.0)  ; this is the scale factor 9.0
       (1070 . 140) (1040 . 6.0)
    (1002 . "}")))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Modify arrowhead size in a leader
« Reply #2 on: March 27, 2008, 12:08:05 PM »
Quote
How do you modify the arrowhead size of an existing leader or dimension with LISP or VLISP?
Code: [Select]
(vl-load-com)
(vlax-put-property
  (vlax-ename->vla-object (car (entsel)))
  'ArrowheadSize
  3.0
)

septicad

  • Guest
Re: Modify arrowhead size in a leader
« Reply #3 on: March 27, 2008, 12:28:53 PM »
Thanks for the replies... if I use an entget then no xData info is displayed... is this a Bricscad thing?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CODE;;;;;;;;;;;;;;;;;;;;;;;;;;;
: elist
Select entity:

(
   (-1 . <Entity name: 0bd8e760>)
   (0 . "LEADER")
   (5 . "18F24")
   (330 . <Entity name: 0bd43d78>)
   (100 . "AcDbEntity")
   (67 . 0)
   (410 . "MODEL")
   (8 . "SEPTICAD")
   (62 . 256)
   (48 . 1.0)
   (284 . 0)
   (100 . "AcDbLeader")
   (3 . "SEPTICAD")
   (71 . 1)
   (72 . 0)
   (73 . 0)
   (74 . 0)
   (75 . 1)
   (40 . 2.06807)
   (41 . 7.96196)
   (76 . 3)
   (10 379.395 163.411 0.0)
   (10 386.775 176.513 0.0)
   (10 389.775 176.513 0.0)
   (340 . <Entity name: 0bd77870>)
   (211 1.0 0.0 0.0)
   (212 0.0 0.0 0.0)
   (213 0.0 0.0 0.0)
   (210 0.0 0.0 1.0)
)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Modify arrowhead size in a leader
« Reply #4 on: March 27, 2008, 12:43:20 PM »
Vovka has shown how the xdata can be updated / changed easly.

You can view the xdata with this:

Code: [Select]
;;  CAB 01.17.08
(defun c:GetXData (/ ent dic result massoc listdictionaries)
  (if (setq ent (car (entsel "\nSelect object to get dictionary.")))
    (print (assoc -3 (entget ent '("*"))))
  )
  (princ)
)

As you can see all you need is (entget ent '("*"))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

septicad

  • Guest
Re: Modify arrowhead size in a leader
« Reply #5 on: March 27, 2008, 01:19:58 PM »
Thank You!! Vovka & CAB...

Clearly, I need to starting using VLISP for higher level functionality.

Steve

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Modify arrowhead size in a leader
« Reply #6 on: March 27, 2008, 02:09:13 PM »
Here is a quickie.
Code: [Select]
;;  Set Leader Size
;;  CAB 03.27.2008
(defun c:LeaderSize (/ size ss lst)
  (vl-load-com)
  (or *LedSize* (setq *LedSize* 3.0))
  (initget 6)
  (setq size (getdist (strcat "\nEnter new Leader Arrow Size. " (rtos *LedSize* 2 3))))
  (and size (setq *LedSize* size))
  (or size (setq size *LedSize*))
 
  (and (princ "\Select Leaders to update.")
       (setq ss (ssget '((0 . "LEADER"))))
       (setq lst (mapcar 'vlax-ename->vla-object
                         (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))
       (mapcar '(lambda(x) (vlax-put-property x 'ArrowheadSize size))  lst)
       )
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

septicad

  • Guest
Re: Modify arrowhead size in a leader
« Reply #7 on: March 27, 2008, 04:27:38 PM »
Here is what I came up with based on the advice in this thread. Its verbose... but easier for me to understand.  My first VLISP coding attempt.  Thanks for all the help.

Code: [Select]
; Changes entities [DIMENSION, LEADER, MTEXT, TEXT] textHeight and arrowHeadSize
(defun c:tst (/ cnt ssetMtext ssetLeader ssettText ssetDimension sset1 obj)

  ; function defines page2TextSize and scaleArrowSize
  ;(if (= page2TextSize nil)(getUserVars))
   (setq page2TextSize 6
scaleArrowSize 1.5)

  ; create empty lists
  (setq ssetDimension (list)
ssetLeader (list)
ssetMtext (list)
ssetText (list))

; get big selection set
 (if (setq sset1 (ssget))
  (progn
   ; create selection sets for different entity types, ignoring other types
   (setq cnt 0)
   (while (< cnt (sslength sset1))

(setq ent (entget (ssname sset1 cnt)))

(if (= (cdr(assoc 0 ent)) "DIMENSION")
  (setq ssetDimension (append ssetDimension (list (ssname sset1 cnt))))
)

(if (= (cdr(assoc 0 ent)) "LEADER")
  (setq ssetLeader (append ssetLeader (list (ssname sset1 cnt))))
)

(if (= (cdr(assoc 0 ent)) "MTEXT")
  (setq ssetMtext (append ssetMtext (list (ssname sset1 cnt))))
)

(if (= (cdr(assoc 0 ent)) "TEXT")
  (setq ssetText (append ssetText (list (ssname sset1 cnt))))
)

(setq cnt (1+ cnt))
   ); end while


  (vl-load-com)

; change properties of DIMENSION selection set
  (foreach item ssetDimension
    (setq obj (vlax-ename->vla-object item))
    (vlax-put-property
      obj
      'TextHeight
      page2TextSize
    )
    (vlax-put-property
      obj
      'ArrowheadSize
      (* scaleArrowSize page2TextSize)
    )
  )


; change properties of LEADER selection set
  (foreach item ssetLeader
    (setq obj (vlax-ename->vla-object item))
    (vlax-put-property
      obj
      'ArrowheadSize
      (* scaleArrowSize page2TextSize)
    )
  )

; change properties of LEADER selection set
  (foreach item ssetMtext
    (setq obj (vlax-ename->vla-object item))
    (vlax-put-property
      obj
      'Height
      page2TextSize
    )
  )

; change properties of TEXT selection set
  (foreach item ssetText
    (setq obj (vlax-ename->vla-object item))
    (vlax-put-property
      obj
      'Height
      page2TextSize
    )
  )

 (command "regen")

 ); end progn
); end if



(princ)
)

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Modify arrowhead size in a leader
« Reply #8 on: March 27, 2008, 04:49:08 PM »
not bad for the first attempt :)
keep in mind that
  there is no need to create empty lists when they are declared as local varibles
  (setq ssetDimension (cons (ssname sset1 cnt) ssetDimension)) is a better way to add atoms to a list

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Modify arrowhead size in a leader
« Reply #9 on: March 28, 2008, 12:33:53 AM »
Very good first attempt. Keep it up.  :-)

I would do it this way, to give you some ideas to consider.
Code: [Select]
;; Changes entities [DIMENSION, LEADER, MTEXT, TEXT] textHeight and arrowHeadSize
(defun c:tst (/ cnt sset1 obj)
  (vl-load-com)

  ;; function defines page2TextSize and scaleArrowSize
  ;;(if (= page2TextSize nil)(getUserVars))
  (setq page2TextSize 6
        scaleArrowSize 1.5
  )
  ;; get big selection set
  (prompt "\nSelect objects to update.")
  (if (setq sset1 (ssget))
    (progn
      ;; create selection sets for different entity types, ignoring other types
      (setq cnt -1)
      (while (< (setq cnt (1+ cnt)) (sslength sset1))
        (setq obj     (vlax-ename->vla-object (ssname sset1 cnt))
              ObjType (vla-get-ObjectName obj)
        )
        (cond
          ((= ObjType '"AcDbRotatedDimension")
           (vlax-put-property obj 'TextHeight page2TextSize)
           (vlax-put-property
             obj
             'ArrowheadSize
             (* scaleArrowSize page2TextSize)
           )
          )
          ((= ObjType "AcDbLeader")
           (vlax-put-property
             obj
             'ArrowheadSize
             (* scaleArrowSize page2TextSize)
           )
          )
          ((= ObjType "AcDbMText")
           (vlax-put-property obj 'Height page2TextSize)
          )
          ((= ObjType "AcDbText")
           (vlax-put-property obj 'Height page2TextSize)
          )
        )
      )   ; end while

      (command "regen")

    )     ; end progn
  )       ; end if

  (princ)
)
« Last Edit: March 28, 2008, 08:22:00 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

septicad

  • Guest
Re: Modify arrowhead size in a leader
« Reply #10 on: March 28, 2008, 08:18:10 AM »
Thank You!!! both for the constructive criticism... The advice is much appreciated.

steve