Author Topic: Add attributes one the fly  (Read 11553 times)

0 Members and 1 Guest are viewing this topic.

Jürg Menzi

  • Swamp Rat
  • Posts: 597
  • Oberegg, Switzerland
Re: Add attributes one the fly
« Reply #15 on: December 14, 2005, 07:18:30 AM »
That's a big DITTO!!!!  You have all kinds of troubles with your blocks then which is what randy was trying to say.  If you change a block and add an attribute to it, then the only way (even after redefining the block) for the previously inserted block defs to have the correct attributes is an attsync. (...)
That's the reason for my suggestion to copy the block definition to a new name. In my solution I use the old block name and append a random number: MyOldBlockName_nnnnnnnn
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k14... A2k18 - Start R2.18

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Add attributes one the fly
« Reply #16 on: December 14, 2005, 11:13:17 AM »
This was and idea.  I like the fact of title blocks being xrefs, but I don't like having so much loose text associated with them, this way one could have an xref'ed title block with attributes.  But mostly it was just an idea I saw from another post, and just wondered if it was possible.  I might never use it because I don't have control over the title blocks where I work.  I can't give any other ideas right now, but if I think of some I will let you all know.

Kerry,
 Thanks for pointing out that I didn't make a variable local.  I write my code, and then at the end go back and make them all local.  I think I was too happy that I got it to work that I missed so minor things that I usually don't, like what Jeff pointed out first.  I was thinking ActiveX first, but didn't think it could be done, but that would be fun to look into.

Thanks for all the comments and corrections.
Tim
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Add attributes one the fly
« Reply #17 on: December 14, 2005, 12:08:21 PM »
If anyone would be so kind as to post how to create blocks on the fly with ActiveX controls I will experiment when I have some time.  I don't see how it is done when looking through the help files.

Thanks.
Tim
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: Add attributes one the fly
« Reply #18 on: December 14, 2005, 12:16:10 PM »
Hi Tim,

Here are some portions of code I have done in the past to generate via vlisp-activex blocks with attributes, HTH

Code: [Select]
;;; Command: RWIZ-BUBBLE
;;;
;;; Description: Generates a circle bubble symbol
;;;
;;; Objects:
;;; 1. Bubble block
;;; - Circle
;;; - One attribute
;;;=============================================================

(defun circular-bubble-blk  (/ radius    p0
     vla_circle ss    obj
     vla_block vla_att1   block_name
     return)

  (setq block_name "RWIZ-REF-CIRCLE")

  (cond
    ;; the block already exist, return the name
    ((not
       (vl-catch-all-error-p
(setq vla_block (vl-catch-all-apply
   'vla-item
   (list (vla-get-blocks (rwiz-thisDwg))
block_name)))))
     (setq return (vla-get-name vla_block)))

    ;; make the block
    ((vl-catch-all-error-p
       (vl-catch-all-apply
'vla-item
(list (vla-get-blocks (rwiz-thisdwg)) block_name)))

     (setq radius 0.15625)

     (setq p0 (list 0.0 0.0 0.0))

     (setq vla_circle (rwiz-addcircle p0 radius))

     (vla-put-layer vla_circle "0")
     (vla-put-color vla_circle acbyblock)

     (setq ss (ssadd))
     (ssadd (vlax-vla-object->ename vla_circle) ss)

     (setq vla_block (rwiz-addblock
       (list 0.0 0.0 0.0)
       block_name
       ss
       T))

     (setq
       vla_att1 (vla-addattribute
  vla_block
  0.09375
  acattributemodeverify
  "NUMBER"
  (vlax-3D-Point p0)
  "NUM"
  "#"))

     (vla-put-layer vla_att1 "0")
     (vla-put-color vla_att1 acbyblock)

     (vla-put-alignment vla_att1 acalignmentmiddlecenter)
     (vla-put-verify vla_att1 :vlax-false)
     (vla-put-textalignmentpoint vla_att1 (vlax-3D-Point p0))

     (setq return (vla-get-name vla_block))))
  return)

LE

  • Guest
Re: Add attributes one the fly
« Reply #19 on: December 14, 2005, 12:17:23 PM »
Another sample:

Code: [Select]
;;; Description: Generates a detail symbol
;;;
;;; Objects:
;;; 1. Bubble block
;;; - Circle
;;; - Two attributes
;;; 2. Two lines
;;;=============================================================

;;;_____________________________________________________________
(defun reference-bubble-blk  (/ radius   rad/2     p0
      vla_circle   p1     p2
      vla_line p3   p4     ss
      obj vla_block vla_att1  vla_att2
      block_name   return)

  ;; name of the block
  (setq block_name "REF-BUBBLE")

  (cond
    ;; the block already exist, return the name
    ((not
       (vl-catch-all-error-p
(setq vla_block (vl-catch-all-apply
   'vla-item
   (list (vla-get-blocks (rwiz-thisDwg))
block_name)))))
     (setq return (vla-get-name vla_block)))

    ;; make the block
    ((vl-catch-all-error-p
       (vl-catch-all-apply
'vla-item
(list (vla-get-blocks (rwiz-thisdwg)) block_name)))

     ;; basic data for the block
     (setq radius 0.25)
     (setq rad/2 (/ radius 2.0))
     (setq p0 (list 0.0 0.0 0.0))

     ;; draw the vla_circle
     (setq vla_circle (rwiz-addCircle p0 radius))
     (vla-put-layer vla_circle "0")
     (vla-put-color vla_circle acbyblock)

     (setq p1 (polar p0 pi radius))
     (setq p2 (polar p0 0.0 radius))

     ;; draw the vla_line
     (setq vla_line (rwiz-addLine p1 p2))
     (vla-put-layer vla_line "0")
     (vla-put-color vla_line acbyblock)

     (setq p3 (polar p0 :rwiz_90Degrees rad/2))
     (setq p4 (polar p0 :rwiz_270Degrees rad/2))

     ;; create a selection set
     (setq ss (ssadd))
     ;; pass all the new objects to the selection set
     (foreach obj  (list vla_circle vla_line)
       (ssadd (vlax-vla-object->ename obj) ss))

     ;; generate the block
     (setq
       vla_block (rwiz-addBlock
   (list 0.0 0.0 0.0)
   block_name
   ss
   T))

     ;; generate the first attribute object
     (setq
       vla_att1 (vla-addattribute
  vla_block
  0.09375
  acattributemodeverify
  "DETAIL_NUMBER"
  (vlax-3D-Point p3)
  "DNUMBER"
  "#"))

     ;; pass the attribute object
     ;; to layer "0" and use of "byblock"
     (vla-put-layer vla_att1 "0")
     (vla-put-color vla_att1 acbyblock)

     ;; place the attribute centered
     (vla-put-alignment vla_att1 acalignmentmiddlecenter)
     ;; do not use the attribute verification
     ;; when inserted
     (vla-put-verify vla_att1 :vlax-false)
     ;; place the attribute in the his position
     (vla-put-textalignmentpoint vla_att1 (vlax-3D-Point p3))

     ;; generate the second attribute
     (setq
       vla_att2
(vla-addattribute
  vla_block
  0.09375
  acattributemodeverify
  "SHEET_NUMBER"
  (vlax-3D-Point p4)
  "SNUMBER"
  "#"))

     (vla-put-layer vla_att2 "0")
     (vla-put-color vla_att2 acbyblock)

     ;; place the attribute centered
     (vla-put-alignment vla_att2 acalignmentmiddlecenter)
     ;; do not use the attribute verification
     ;; when inserted
     (vla-put-verify vla_att2 :vlax-false)
     ;; place the attribute in the his position
     (vla-put-textalignmentpoint vla_att2 (vlax-3D-Point p4))

     (setq return (vla-get-name vla_block))))
  return)

LE

  • Guest
Re: Add attributes one the fly
« Reply #20 on: December 14, 2005, 12:18:34 PM »
Another one:

Code: [Select]
;;; Description: Generates a keynote symbol
;;;
;;; Objects:
;;; 1. Bubble block
;;; - Circle
;;; - One attribute
;;; 2. One line
;;; 3. Arrowhead
;;; - Lwpolyline
;;; - Hatch
;;;=============================================================

;;;_____________________________________________________________
(defun keynote-bubble-blk  (/        radius   p0      vla_circle
    ss        obj   vla_block  vla_att1
    block_name return)

  (setq block_name "SYM-REF-CIRCLE")

  (cond
    ;; the block already exist, return the name
    ((not
       (vl-catch-all-error-p
(setq vla_block (vl-catch-all-apply
   'vla-item
   (list (vla-get-blocks (rwiz-thisdwg))
block_name)))))
     (setq return (vla-get-name vla_block)))

    ;; make the block
    ((vl-catch-all-error-p
       (vl-catch-all-apply
'vla-item
(list (vla-get-blocks (rwiz-thisdwg)) block_name)))

     (setq radius 0.15625)

     (setq p0 (list 0.0 0.0 0.0))

     ;; make the circle
     (setq vla_circle (rwiz-addcircle p0 radius))

     ;; put the circle on layer 0
     (vla-put-layer vla_circle "0")
     ;; put the circle by block
     (vla-put-color vla_circle acbyblock)

     ;; make an empty selection set
     (setq ss (ssadd))
     ;; pass the object to selection set
     (ssadd (vlax-vla-object->ename vla_circle) ss)

     ;; make the block
     (setq vla_block (rwiz-addblock
       (list 0.0 0.0 0.0)
       block_name
       ss
       T))

     ;; make the attribute
     (setq
       vla_att1 (vla-addattribute
  vla_block
  0.09375
  acattributemodeverify
  "NUMBER"
  (vlax-3d-point p0)
  "NUM"
  "#"))

     ;; put the attribute on layer 0
     (vla-put-layer vla_att1 "0")
     ;; put the attribute by block
     (vla-put-color vla_att1 acbyblock)

     ;; align the attribute middle center
     (vla-put-alignment vla_att1 acalignmentmiddlecenter)
     ;; not verify the attribute at insertion
     (vla-put-verify vla_att1 :vlax-false)
     ;; put the attribute on his alignment point
     (vla-put-textalignmentpoint vla_att1 (vlax-3d-point p0))

     ;; block name
     (setq return (vla-get-name vla_block))))
  return)

LE

  • Guest
Re: Add attributes one the fly
« Reply #21 on: December 14, 2005, 12:20:08 PM »
and some utilities, that you might have done it already:

Code: [Select]
;;;=============================================================
;;; REACTORSWIZ [Version 1.0.0 - 3/4/04]
;;; Copyright © 2003-2004, Luis Esquivel
;;;
;;;    The use of this software is governed by the terms and
;;; conditions of the License Agreement you accepted prior
;;; to installation of this software. Read the License
;;; Agreement file: RWIZ_LICENSE_AGREEMENT.TXT
;;;
;;;    LUIS ESQUIVEL PROVIDES THIS PROGRAM "AS IS" AND WITH
;;; ALL FAULTS. LUIS ESQUIVEL SPECIFICALLY DISCLAIMS ANY
;;; IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A
;;; PARTICULAR USE. LUIS ESQUIVEL DOES NOT WARRANT THAT
;;; THE OPERATION OF THE PROGRAM WILL BE UNINTERRUPTED
;;; OR ERROR FREE.
;;;
;;;    Use, duplication, or disclosure by the U.S. Government
;;; is subject to restrictions set forth in FAR 52.227-19
;;; (Commercial Computer Software - Restricted Rights) and
;;; DFAR 252.227-7013(c)(1)(ii) (Rights in Technical Data
;;; and Computer Software), as applicable.
;;;
;;; Luis Esquivel
;;;
;;; Function utilities
;;;
;;; Note:
;;; Please note that only the functions with my initials LE
;;; were written and are copyright by Luis Esquivel.
;;; Others are copyright by their own owners.
;;;=============================================================

;; degrees
(setq :rwiz_45degrees (* pi 0.25))
(setq :rwiz_90degrees (* pi 0.5))
(setq :rwiz_135degrees (* pi 0.75))
(setq :rwiz_225degrees (* pi 1.25))
(setq :rwiz_270degrees (* pi 1.5))
(setq :rwiz_315degrees (* pi 1.75))
(setq :rwiz_360degrees (* pi 2.0))

;;;_____________________________________________________________

;; get acad object object
;; LE
(or :rwiz_acad
    (setq :rwiz_acad (vlax-get-acad-object)))

;;;_____________________________________________________________

;;; get active drawing object
;;; LE
(defun rwiz-thisdwg () (vla-get-activedocument :rwiz_acad))

;; global variable for this drawing
;; LE
;;;(or :rwiz_thisdwg (setq :rwiz_thisdwg (rwiz-thisdwg)))

(setq
  :rwiz_thisdwg
   (cond (:rwiz_thisdwg)
((rwiz-thisdwg))
(t (rwiz-thisdwg))))

;;;_____________________________________________________________

;; get model space object
;; LE
(or :rwiz_model
    (setq :rwiz_model
   (vla-get-modelspace (rwiz-thisdwg))))

;;;_____________________________________________________________

;;; get paper space object
;;; LE
(defun rwiz-pspace () (vla-get-paperspace (rwiz-thisdwg)))

;;;_____________________________________________________________

;;; get active space object
(defun rwiz-get-activespace  ()
  (if (= acmodelspace (vla-get-activespace (rwiz-thisdwg)))
    :rwiz_model
    (if (= (vla-get-mspace (rwiz-thisdwg)) :vlax-true)
      :rwiz_model
      (rwiz-pspace))))

;;;_____________________________________________________________

;;; get active space name "Model" or "Paper"
(defun rwiz-activespacename  ()
  (cond
    ((= acmodelspace (vla-get-activespace (rwiz-thisdwg)))
     "Model")
    (t
     (if (= (vla-get-mspace (rwiz-thisdwg)) :vlax-true)
       "Model"
       "Paper"))))

;;;_____________________________________________________________

;;; adjust dimscale, it will use 1.0 factor when is in paper space
;;; sc = scale factor as real
;;; LE
(defun rwiz-adjust-dimscale  (sc)
  (if (= (rwiz-activespacename) "Model")
    sc
    1.0))

;;;_____________________________________________________________

;;; list to variant array
;;; ptslist = point list
(defun rwiz-list-variantarray  (ptslist / arrayspace sarray)
  (setq arrayspace
(vlax-make-safearray
   ;; element type
   vlax-vbdouble
   ;; array dimension
   (cons 0
(- (length ptslist) 1))))
  (setq sarray (vlax-safearray-fill arrayspace ptslist))
  ;; return array variant
  (vlax-make-variant sarray))

;;;_____________________________________________________________

;;; 3d point to 2d point
;;; 3dpt = 3d point
(defun rwiz-3dpt-2dpt  (3dpt)
  (list (float (car 3dpt)) (float (cadr 3dpt))))

;;;_____________________________________________________________

;;; selection set to vla objects list
;;; ss = selection set
(defun rwiz-ss-vla-list (ss / index vlalist)
  (setq index (if ss
(1- (sslength ss))
-1))
  (while (>= index 0)
    (setq vlalist (cons
    (vlax-ename->vla-object
      (ssname ss index))
    vlalist)
  index   (1- index)))
  vlalist)

;;;_____________________________________________________________

;;; selection set to array
;;; ss = selection set
(defun rwiz-ss-array  (ss / c r)
  (setq c -1)
  (repeat (sslength ss)
    (setq r (cons (ssname ss (setq c (1+ c))) r)))
  (setq r (reverse r))
  (vlax-safearray-fill
    (vlax-make-safearray
      vlax-vbobject
      (cons 0 (1- (length r))))
    (mapcar 'vlax-ename->vla-object r)))

;;;_____________________________________________________________

;;; array of vbobject's
;;; vla_lst = vla-object list
;;; LE
(defun rwiz-array-vbobject  (vla_lst)
  (vlax-safearray-fill
    (vlax-make-safearray
      vlax-vbobject
      (cons 0 (1- (length vla_lst))))
    vla_lst))

;;;_____________________________________________________________

;;; make block
;;; usage:
;;; (rwiz-makeblock (list 0.0 0.0 0.0) "BLOCKNAME" selection_set T)
;;; flag:
;;; t = delete objects
;;; nil = keep objects
;;; LE
(defun rwiz-makeblock  (pt name ss flag / ssarray vla_block)
  (vla-copyobjects
    (rwiz-thisdwg)
    (setq ssarray (rwiz-ss-array ss))
    (setq vla_block (vla-add (vla-get-blocks (rwiz-thisdwg))
     (vlax-3d-point pt)
     name)))
  ;; delete objects
  (if (and flag
   ssarray
   (= (type ssarray) 'safearray)
   ;; is the safearray made of vlax-object's
   (= (vlax-safearray-type ssarray) 9))
    (mapcar 'vla-delete (safearray-value ssarray)))
  vla_block)

;;;_____________________________________________________________

;;; add block
;;; usage:
;;; (rwiz-addblock (list 0.0 0.0 0.0) "BLOCKNAME" selection_set T)
;;; flag:
;;; t = delete objects
;;; nil = keep objects
;;; LE
(defun rwiz-addblock  (pt name ss flag / vla_block)
  (if (not (vl-catch-all-error-p
     (setq vla_block
    (vl-catch-all-apply
      'rwiz-makeblock
      (list pt name ss flag)))))
    vla_block))

;;;_____________________________________________________________

;;; insert block
;;; (rwiz-insertBlock (list 0.0 0.0 0.0) "BLOCKNAME" 1.0 1.0 1.0 0.0)
;;; LE
(defun rwiz-insertblock
(insertionpoint   name
  xscale      yscale   zscale
  rotation    /   vla_insert)
  (if (not (vl-catch-all-error-p
     (setq vla_insert
    (vl-catch-all-apply
      'vla-insertblock
      (list (rwiz-get-activespace)
    (vlax-3d-point insertionpoint)
    name
    xscale
    yscale
    zscale
    rotation)))))
    vla_insert))

;;;_____________________________________________________________

;;; add circle
;;; usage:
;;; (rwiz-addcircle (list 0.0 0.0 0.0) 4.0)
;;; LE
(defun rwiz-addcircle  (center radius / vla_circle)
  (if (not (vl-catch-all-error-p
     (setq vla_circle
    (vl-catch-all-apply
      'vla-addcircle
      (list (rwiz-get-activespace)
    (vlax-3d-point center)
    radius)))))
    vla_circle))

;;;_____________________________________________________________

;;; add lwpolyline
;;; (rwiz-addlwpoly (list p1 p2 p3 p4) t)
;;; flag:
;;; t = closed
;;; nil = not closed
(defun rwiz-addlwpoly  (lst flag / vla_poly)
  (if (not (vl-catch-all-error-p
     (setq vla_poly
    (vl-catch-all-apply
      'vla-addlightweightpolyline
      (list (rwiz-get-activespace)
    (rwiz-list-variantarray
      (apply 'append
     (mapcar 'rwiz-3dpt-2dpt lst))))))))
    (if flag
      (vla-put-closed vla_poly t)))
  vla_poly)

;;;_____________________________________________________________

;;; add line
;;; usage:
;;; (rwiz-addline (list 0.0 0.0 0.0) (list 4.0 4.0 0.0))
;;; LE
(defun rwiz-addline  (start_point end_point / vla_line)
  (if (and start_point
   end_point
   (not (vl-catch-all-error-p
  (setq
    vla_line
     (vl-catch-all-apply
       'vla-addline
       (list (rwiz-get-activespace)
     (vlax-3d-point start_point)
     (vlax-3d-point end_point)))))))
    vla_line))

;;;_____________________________________________________________

;;; degrees to radians
(defun rwiz-dtr (x) (* pi (/ x 180.0)))

;;;_____________________________________________________________

;;; radians to degrees
(defun rwiz-rtd (a) (* (/ a pi) 180.0))

;;;_____________________________________________________________

;;; dxf
(defun rwiz-dxf (g e)
  (cond
    ((= (type e) 'ename) (cdr (assoc g (entget e))))
    ((= (type e) 'list) (cdr (assoc g e)))))

;;;_____________________________________________________________

;;; get attributes from a block
;;; LE
(defun rwiz-get-attributes  (vla_blk / lst)
  (if (and vla_blk
   (= (type vla_blk) 'vla-object)
   (not (vlax-erased-p vla_blk))
   (= (vla-get-objectname vla_blk) "AcDbBlockReference")
   (= (vla-get-hasattributes vla_blk) :vlax-true)
   (not (vl-catch-all-error-p
  (setq
    lst
     (vl-catch-all-apply
       'vlax-safearray->list
       (list (vlax-variant-value
       (vla-getattributes vla_blk))))))))
    lst
    nil))

;;;_____________________________________________________________

;;; check if all characters are lowercase
;;; (rwiz-all-lowercase "adsadsadsadsasad")
(defun rwiz-all-lowercase  (string)
  (vl-every
    (function
      (lambda (ltr)
(and (>= (chr ltr) "a") (<= (chr ltr) "z"))))
    (vl-string->list string)))

;;;_____________________________________________________________

;;; check if all characters are uppercase
;;; (rwiz-all-uppercase "DSADSADSADSADSADSADSADSADSADSADSADSA")
(defun rwiz-all-uppercase  (string)
  (vl-every
    (function
      (lambda (ltr)
(and (>= (chr ltr) "A") (<= (chr ltr) "Z"))))
    (vl-string->list string)))

;;;_____________________________________________________________

;;; return T if all elements in a list are equal:
(defun rwiz-list-equal (lst / first)
  (setq first (car lst))
  (vl-every (function (lambda (x) (equal first x 0.0001)))
    (cdr lst)))

;;;_____________________________________________________________

;;; check if a block is uniform scaled
;;; LE
(defun rwiz-get-uniform-scale-factor  (vla_blk)
  (rwiz-list-equal
    (list (vla-get-xscalefactor vla_blk)
  (vla-get-yscalefactor vla_blk)
  (vla-get-zscalefactor vla_blk))))

;;;_____________________________________________________________

;;; make a block uniform scaled base on a scale factor
;;; LE
(defun rwiz-put-uniform-scale-factor  (vla_blk factor / flag)
  (if (vlax-write-enabled-p vla_blk)
    (progn
      (if (/= (vla-get-xscalefactor vla_blk) factor)
(progn
  (vla-put-xscalefactor vla_blk factor)
  (setq flag t)))

      (if (/= (vla-get-yscalefactor vla_blk) factor)
(progn
  (vla-put-yscalefactor vla_blk factor)
  (setq flag t)))

      (if (/= (vla-get-zscalefactor vla_blk) factor)
(progn
  (vla-put-zscalefactor vla_blk factor)
  (setq flag t)))))
  flag)

;;;_____________________________________________________________

;;; scan a ename block and return a list of type and ename
;;; (rwiz-scanblock-lst blk)
;;; (("TEXT" <Entity name: 7ef57ec0>)
;;;  ("LINE" <Entity name: 7ef57ec8>)
;;;  ("CIRCLE" <Entity name: 7ef57ed0>)
;;;  ("LWPOLYLINE" <Entity name: 7ef57ed8>))
;;; LE
(defun rwiz-scanblock-lst  (blk / enext entnames)
  (setq enext
(cdr
   (assoc
     -2
     (tblsearch
       "block"
       (rwiz-dxf 2 (entget blk))))))
  (while enext
    (setq entnames
   (cons (list (rwiz-dxf 0 (entget enext)) enext)
entnames))
    (setq enext (entnext enext)))
  (reverse entnames))

;;;_____________________________________________________________

;;; translate a list of point to a base point
;;; LE
(defun rwiz-transpts  (lst pt / p0 p1 ang pin ang pt1 lst1)
  (setq p0  (car lst)
p1  (cadr lst)
ang (angle p0 p1)
pin (inters p0 p1 pt (polar pt (+ ang (/ pi 2)) 1) nil)
ang (angle pin pt))
  (foreach p  lst
    (setq pt1  (polar p ang (distance pt pin))
  lst1 (append lst1 (list pt1))))
  lst1)

;;;_____________________________________________________________

;;; convert the array to a list
;;; LE
(defun rwiz-get-insertionpoint (vla_obj)
  (vlax-safearray->list
    (vlax-variant-value
      (vla-get-insertionpoint vla_obj))))

;;;_____________________________________________________________

;;; convert the array to a list
;;; LE
(defun rwiz-get-startpoint  (vla_obj)
  (vlax-safearray->list
    (vlax-variant-value
      (vla-get-startpoint vla_obj))))

;;;_____________________________________________________________

;;; convert the array to a list
;;; LE
(defun rwiz-get-endpoint  (vla_obj)
  (vlax-safearray->list
    (vlax-variant-value
      (vla-get-endpoint vla_obj))))

;;;_____________________________________________________________

;;; ability to drag an move a vla object
;;; msg: optional message by default uses "Move"
;;; LE
(defun rwiz-drag-move  (msg vla_obj / take code5 p3)
  (prompt (strcat "\n"
  (cond (msg)
("Move"))
  "\n"))
  (while (and (setq take (grread 't)) (/= 3 (car take)))
    (setq code5 (car take))
    (setq p3 (cadr take))
    (if (and p3 (= 5 code5))
      (vla-move vla_obj
(vla-get-insertionpoint vla_obj)
(vlax-3d-point p3)))))

;;;_____________________________________________________________

;;; (rwiz-unhighligthem ss)
(defun rwiz-unhighligthem  (ss)
  (sssetfirst nil ss)
  (sssetfirst nil))

;;;_____________________________________________________________

(princ)
« Last Edit: December 14, 2005, 12:28:34 PM by LE »

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Add attributes one the fly
« Reply #22 on: December 14, 2005, 12:34:28 PM »
Luis,
  Thanks for sharing.  I was looking at the code, and it looks to me that you are adding a block to the block collection.  Is that true?  Does that do the same thing as entmake?  I didn't think it did, but I could be wrong.  I was looking for something that did the same thing as entmake but with ActiveX controls.  If your code is the right way to do it, then I don't think it can be done because it changes the block definition, and that is what I was trying to avoid.

Tim
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: Add attributes one the fly
« Reply #23 on: December 14, 2005, 12:40:58 PM »
Yes.... but there are ways in activex to add or remove parts of a block directly.... let me see if I have done such.... don't remember.

hmm... sorry I did not read the whole [enchilada] topic.


Luis.

LE

  • Guest
Re: Add attributes one the fly
« Reply #24 on: December 14, 2005, 12:48:25 PM »
Tim;

Have you been lately at the www.acadx.com ? there is some visual lisp functions that might help you... ie. ax:AddObjectsToBlock ?

HTH.

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Add attributes one the fly
« Reply #25 on: December 14, 2005, 12:54:15 PM »
Luis,
  I haven't been there in awhile, but they didn't have anything that looks like what I'm trying to do.  Thanks for reminding me about that site though.

Tim
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Jeff_M

  • King Gator
  • Posts: 3948
  • C3D user & customizer
Re: Add attributes one the fly
« Reply #26 on: December 14, 2005, 01:36:46 PM »
Tim, the Add method to the Blocks collection is sorta the same as entmake for a block definition, except the EndBlock is added for you and you can place anything into the block. However, there is no ActiveX equal for entmaking an insert, since the AddInsert method inserts the block & all attributes.

FWIW, this may be a viable option for what your concerns were: "I like the fact of title blocks being xrefs, but I don't like having so much loose text associated with them, this way one could have an xref'ed title block with attributes". Why not use an Xref for all static portions of the Title Block and use a standard block w/attributes for the "loose" text/attributes? This way your Title block is composed of 2 objects (which you could Group together).

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Add attributes one the fly
« Reply #27 on: December 14, 2005, 01:45:15 PM »
However, there is no ActiveX equal for entmaking an insert, since the AddInsert method inserts the block & all attributes.
Thanks for the comformation.  I had thought this, but wasn't sure.
FWIW, this may be a viable option for what your concerns were: "I like the fact of title blocks being xrefs, but I don't like having so much loose text associated with them, this way one could have an xref'ed title block with attributes". Why not use an Xref for all static portions of the Title Block and use a standard block w/attributes for the "loose" text/attributes? This way your Title block is composed of 2 objects (which you could Group together).
I have used this in the past.  The problems is that it can be moved by someone, so that they are not lined up anymore.  I have done this, and have made it easy to use, but they still get messed up, and the only time you see it is when it is already plotted.  This was an idea so that you won't have that problem at all.

This was a fun exercise for me.  I can never seem to get entmake to work for me, so I wanted to see if I could.  Too bad it can't be done with ActiveX controls, that would have been fun to try also.

Thanks everyone for the contributions, code and knowledge.  It was a great learning experience for me.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: Add attributes one the fly
« Reply #28 on: December 14, 2005, 03:01:28 PM »
Should I remove all the code samples [I posted]... since they do not apply here ?

Thanks.

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Add attributes one the fly
« Reply #29 on: December 14, 2005, 03:08:20 PM »
Should I remove all the code samples [I posted]... since they do not apply here ?

Thanks.

I would say no because maybe someone searching could use them.  But that is just me.  It makes good reading.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.