Page 5 of 7 FirstFirst 1234567 LastLast
Results 41 to 50 of 64

Thread: Reference information from tables into blocks

  1. #41
    Active Member
    Join Date
    2007-04
    Posts
    50
    Login to Give a bone
    0

    Default Re: Reference information from tables into blocks

    Quote Originally Posted by james.126519 View Post
    I understand what you are saying.

    I dont know much about LISP at all, so bear with me.

    If I have three of the same block in a drawing, and one is 10" long, and the other two are 20" long, and I run the program to lablel them as ABC, it will name the 10" long block ABC1 and both of the 20" long blocks ABC2. At this point, the program has completed. Is there a way to add a variable or something in the program that it keeps a list of all of the parts marks it had created. Then, If i change one of the 20" blocks to 15", and re-run the program, it first consults its list to determine what part marks have been used. It would see that ABC1 (10") has been used and ABC2 (20") has been used, then determine what new blocks are within the selection set (15"), and determine that the next available number for that block is ABC3. Also, if there were already an ABC3 (15") in the drawing from the first run, and I added more of the same part, it would recognize that any new parts with the same length should match what they were part marked originally.

    Hopefully I explained that correctly. Again, I dont know what is or is not possible with LISP.
    While more regulations was setup, it do be possible for vlisp and of coz that will make the program little more complex. however, as for ur request, I have tried to add some comments on the routine so that you can understand the logic procedure and regulation of the new program and help ur programming skills as well. I have not got enough time and data to make adequate test. Just try it.
    Code:
    ;|
    Regulations for GlassTAG2
    
    Once the glasses was labeled, the glass attributes will be marked automatically that any change to the attribute content
    will be changed back while the routine is running. If the window's height is changed to other existing valid height, the
    existing label number will be used, otherwise, new additional number will be added.
    
    Copy the glasses will also clone the marked data as well.
    
    Becoz every 1st time the program is running on the rough glasses and the label number system was established based on the
    glasses in the section set. This can be the base group of the Label-System. Mixing the different Label-System may cause
    unknown error. In order to do so, please run ClearTag2 to clear the data marks and then run GlassTag2 again.
    
    |;
    (Defun C:Glasstag2 (/	     block-analysis    make-unique
    		    get-number	      *DD*     AT	BPFX
    		    CALH     II	      PFX      SAVDAT	SAVH
    		    SAVSTR   SN	      SS       STR	TAG
    		    VBLK     XXX
    		   )
    		   ;| Analysis the block attribute, return global var *DD*, only attribute with valid TAG will be recognized.
      Format of *DD*
      (([Str]BlockName1
         ([Real]Height1 [VLO]AttributeObject1 [Str]SavedHeight1 [Str]SavedLabelString1)
         ([Real]Height2 [VLO]AttributeObject2 [Str]SavedHeight2 [Str]SavedLAbelString2)
         ...
       )
        ([Str]BlockName2
          ([Real]Height1 [VLO]AttributeObject1 [Str]SavedHeight1 [Str]SavedLabelString1)
          ([Real]Height2 [VLO]AttributeObject2 [Str]SavedHeight2 [Str]SavedLabelString2)
          ...
        )
      )
      YY: Calculated Window Height
      SX: Saved Windows Height in last running, if not, use NIL
      SY: Last labled Valid-and-good string
    |;
      (Defun block-analysis	(blk tagx / BN LL SX SY UR XX YY)
        (vla-getboundingbox
          (setq blk (vlax-ename->vla-object blk))
          'll
          'ur
        )
        (setq bn (vla-get-effectivename blk)
    	  ll (vlax-safearray->list ll)
    	  ur (vlax-safearray->list ur)
    	  yy (abs (- (cadr ur) (cadr ll)))
        )
        (foreach at	(vlax-safearray->list
    		  (vlax-variant-value (vla-getattributes blk))
    		)
          (setq sx (vlax-ldata-get (vlax-vla-object->ename at) "GlassTag")
    	    sy (vlax-ldata-get (vlax-vla-object->ename at) "ValidTag")
          )
          (if (member (vla-get-tagstring at) tagx) ; If the tag is valid
    	(if (null (setq xx (cdr (assoc bn *dd*))))
    	  (setq *dd* (cons (list bn (list yy at sx sy)) *dd*))
    					; New data, added directly
    	  (setq	xx   (cons (list yy at sx sy) xx)
    		*dd* (subst (cons bn xx) (assoc bn *dd*) *dd*)
    					; Existing data, update
    	  )
    	)
          )
        )
      )
    ;;; Remove duplicated items
      (Defun make-unique (lst / abc rtn)
        (foreach abc lst
          (if (null (vl-position abc rtn))
    	(setq rtn (cons abc rtn))
          )
        )
        (reverse rtn)
      )
    ;;; Get the proper next useful number from existing data
      (Defun get-number (lst pfx / abc rtn)
        (setq rtn 0)
        (foreach abc lst
          (if (= (type abc) 'str)
    	(setq rtn (max rtn (read (vl-string-subst "" pfx abc))))
          )
        )
        (itoa (1+ rtn))
      )
      ;|
    BPFX: Data list to save the valid Block name and relative Label prefix
    VBLK: Valid Blocks
    TAG: Valid Tags
    |;
      (setq	Bpfx '(("451T-VG-570" "SM")
    	       ("451T-VG-572" "SMP")
    	       ("451T-CG-001" "M")
    	       ("NewBlockNameHere" "NewPrefixStringHere")
    	      )
    	VBlk (mapcar 'car Bpfx)
    	Tag  '("PART-MARK" "NewGlassTagHere")
    	ii   -1
      )
      (princ "\n Valid blocks:")
      (foreach ss VBlk
        (princ (strcat ss "\t"))
      )
      (princ "\n Please select the Glass block(s) <Exit>:")
      (if (setq ss (ssget (list (cons 0 "insert") (cons 66 1))))
        (progn
          (princ (strcat "\n Processing "
    		     (itoa (sslength ss))
    		     " pieces of glasses..."
    	     )
          )
          (repeat (sslength ss)		; Loop selected blocks 1 by 1
    	(if
    	  (member (strcase (vla-get-effectivename
    			     (vlax-ename->vla-object
    			       (setq sn (ssname ss (setq ii (1+ ii))))
    			     )
    			   )
    		  )
    		  VBlk
    	  )
    	   (block-analysis sn Tag)	; Analysis only for valid block names
    	)
          )
          (foreach nn *dd*
    	(setq pfx    (car (cdr (assoc (car nn) Bpfx)))
    	      nn     (cdr nn)
    	      nn     (vl-sort nn '(lambda (p1 p2) (< (car p1) (car p2))))
    					; Sort from small to large
    	      at     (mapcar 'reverse nn)
    	      SavStr (make-unique (mapcar 'car at))
    					; All existing valid label string
    	      SavDat (make-unique (mapcar 'cdr (mapcar 'cdr nn)))
    					; The (ValidHeight ValidString) data
    
    	)				; Format for nn ("BlockName" (HT1 AT1 SAVHT1 VALIDSTR1)(HT2 AT2 SAVHT2 VALIDSTR2)...)
    	(foreach at nn
    					; Format for mm (HTx ATx SavedHeightx SavedLabelx)
    	  (setq	CalH (rtos (nth 0 at) 2 3) ; Calculated Height
    		SavH (nth 2 at)		; Saved Height
    		str  (nth 3 at)		; valid Attrribute Label, maybe not the same as the attribute's content
    		at   (nth 1 at)		; Attribute Object
    	  )
    	  (cond	((= CalH SavH)		; The Calculated height and Saved height is Same
    		 (setq xxx str)
    		)
    		((/= CalH SavH)		; The Calculated height and Saved height is not same, changed or new
    		 (if (null (setq xxx (cdr (assoc CalH SavDat))))
    		   (setq xxx	(strcat pfx (get-number SavStr pfx))
    			 SavStr	(cons xxx SavStr)
    			 SavDat	(cons (list CalH xxx) SavDat)
    					; Create new ID for new height
    		   )
    		   (setq xxx (car xxx))	; Using existing saved label with the proper height
    		 )
    		)
    	  )
    	  (vla-put-textstring at xxx)
    	  (vlax-ldata-put
    	    (vlax-vla-object->ename at)
    	    "GlassTag"
    	    CalH
    	  )
    	  (vlax-ldata-put
    	    (vlax-vla-object->ename at)
    	    "ValidTag"
    	    xxx
    	  )
    	)
          )
          (princ "done!")
        )
      )
      (princ)
    )
    
    (Defun C:Cleartag2 (/ block-clear BPFX II SN SS VBLK)
      (Defun block-clear (blk / at)
        (foreach at	(vlax-safearray->list
    		  (vlax-variant-value
    		    (vla-getattributes (vlax-ename->vla-object blk))
    		  )
    		)
          (if (vlax-ldata-get
    	    (setq at (vlax-vla-object->ename at))
    	    "GlassTag"
    	  )
    	(progn
    	  (vlax-ldata-delete at "GlassTag")
    	  (vlax-ldata-delete at "ValidTag")
    	)
          )
        )
      )
      (setq	Bpfx '(("451T-VG-570" "SM")
    	       ("451T-VG-572" "SMP")
    	       ("451T-CG-001" "M")
    	       ("NewBlockNameHere" "NewPrefixStringHere")
    	      )
    	VBlk (mapcar 'car Bpfx)
    	ii   -1
      )
      (princ "\n Valid blocks:")
      (foreach ss VBlk
        (princ (strcat ss "\t"))
      )
      (princ "\n Please select the Glass block(s) <Exit>:")
      (if (setq ss (ssget (list (cons 0 "insert") (cons 66 1))))
        (progn
          (princ (strcat "\n Processing "
    		     (itoa (sslength ss))
    		     " pieces of glasses..."
    	     )
          )
          (repeat (sslength ss)
    	(if
    	  (member (strcase (vla-get-effectivename
    			     (vlax-ename->vla-object
    			       (setq sn (ssname ss (setq ii (1+ ii))))
    			     )
    			   )
    		  )
    		  VBlk
    	  )
    	   (block-clear sn)
    	)
          )
        )
      )
      (princ "done!\n")
      (princ)
    )
    Last edited by kozmosovia; 2008-04-03 at 12:00 PM.

  2. #42
    100 Club
    Join Date
    2006-11
    Location
    Martinsburg, WV USA
    Posts
    199
    Login to Give a bone
    0

    Default Re: Reference information from tables into blocks

    That code works perfect!

    I do need to understand one thing though. I am constantly modifying blocks to perform different tasks. The blocks that were in the drawing I sent you had two linear paramaters, one to stretch the length of the rectangle, and the other to move the attribute. The code worked great with those blocks. then I realized I needed to change the second linear paramater to a point paramater so i was not restricted to move the attribute in one direction. When I did that, the program started reading the point paramater and assigning tags to the X-position rather than the linear paramter length. Can i rename the linear parameter "distance" to "Extruded Part Length" or something unique so that no matter what I change in the block, as long as that paramater is present the program will read only that paramater? I have attached what I did, as well as my modified code with the block names.
    Code:
    ;|
    Regulations for GlassTAG2
    
    Once the glasses was labeled, the glass attributes will be marked automatically that any change to the attribute content
    will be changed back while the routine is running. If the window's height is changed to other existing valid height, the
    existing label number will be used, otherwise, new additional number will be added.
    
    Copy the glasses will also clone the marked data as well.
    
    Becoz every 1st time the program is running on the rough glasses and the label number system was established based on the
    glasses in the section set. This can be the base group of the Label-System. Mixing the different Label-System may cause
    unknown error. In order to do so, please run ClearTag2 to clear the data marks and then run GlassTag2 again.
    
    |;
    (Defun C:JHUPartMark (/	     block-analysis    make-unique
    		    get-number	      *DD*     AT	BPFX
    		    CALH     II	      PFX      SAVDAT	SAVH
    		    SAVSTR   SN	      SS       STR	TAG
    		    VBLK     XXX
    		   )
    		   ;| Analysis the block attribute, return global var *DD*, only attribute with valid TAG will be recognized.
      Format of *DD*
      (([Str]BlockName1
         ([Real]Height1 [VLO]AttributeObject1 [Str]SavedHeight1 [Str]SavedLabelString1)
         ([Real]Height2 [VLO]AttributeObject2 [Str]SavedHeight2 [Str]SavedLAbelString2)
         ...
       )
        ([Str]BlockName2
          ([Real]Height1 [VLO]AttributeObject1 [Str]SavedHeight1 [Str]SavedLabelString1)
          ([Real]Height2 [VLO]AttributeObject2 [Str]SavedHeight2 [Str]SavedLabelString2)
          ...
        )
      )
      YY: Calculated Window Height
      SX: Saved Windows Height in last running, if not, use NIL
      SY: Last labled Valid-and-good string
    |;
      (Defun block-analysis	(blk tagx / BN LL SX SY UR XX YY)
        (vla-getboundingbox
          (setq blk (vlax-ename->vla-object blk))
          'll
          'ur
        )
        (setq bn (vla-get-effectivename blk)
    	  ll (vlax-safearray->list ll)
    	  ur (vlax-safearray->list ur)
    	  yy (abs (- (cadr ur) (cadr ll)))
        )
        (foreach at	(vlax-safearray->list
    		  (vlax-variant-value (vla-getattributes blk))
    		)
          (setq sx (vlax-ldata-get (vlax-vla-object->ename at) "GlassTag")
    	    sy (vlax-ldata-get (vlax-vla-object->ename at) "ValidTag")
          )
          (if (member (vla-get-tagstring at) tagx) ; If the tag is valid
    	(if (null (setq xx (cdr (assoc bn *dd*))))
    	  (setq *dd* (cons (list bn (list yy at sx sy)) *dd*))
    					; New data, added directly
    	  (setq	xx   (cons (list yy at sx sy) xx)
    		*dd* (subst (cons bn xx) (assoc bn *dd*) *dd*)
    					; Existing data, update
    	  )
    	)
          )
        )
      )
    ;;; Remove duplicated items
      (Defun make-unique (lst / abc rtn)
        (foreach abc lst
          (if (null (vl-position abc rtn))
    	(setq rtn (cons abc rtn))
          )
        )
        (reverse rtn)
      )
    ;;; Get the proper next useful number from existing data
      (Defun get-number (lst pfx / abc rtn)
        (setq rtn 0)
        (foreach abc lst
          (if (= (type abc) 'str)
    	(setq rtn (max rtn (read (vl-string-subst "" pfx abc))))
          )
        )
        (itoa (1+ rtn))
      )
      ;|
    BPFX: Data list to save the valid Block name and relative Label prefix
    VBLK: Valid Blocks
    TAG: Valid Tags
    |;
      (setq	Bpfx '(("450-CG-028 POCKET FILLER" "CPF")
    	       ("400-026 FLAT FILLER" "FF")
    	       ("400-075 CORNER POST" "CP")
    	       ("400-028 SILL FLASHING" "SF")
    	       ("450-CG-002 POCKET FILLER" "PF")
    	       ("400-011 TUBE HORIZONTAL" "H")
    	       ("400-003 SILL" "S")
    	       ("400-001 MULLION" "M")
    	       ("400-004 GLASS STOP" "GS")
    	      )
    	VBlk (mapcar 'car Bpfx)
    	Tag  '("PART-MARK" "NewGlassTagHere")
    	ii   -1
      )
      (princ "\n Valid blocks:")
      (foreach ss VBlk
        (princ (strcat ss "\t"))
      )
      (princ "\n Please select the Glass block(s) <Exit>:")
      (if (setq ss (ssget (list (cons 0 "insert") (cons 66 1))))
        (progn
          (princ (strcat "\n Processing "
    		     (itoa (sslength ss))
    		     " pieces of glasses..."
    	     )
          )
          (repeat (sslength ss)		; Loop selected blocks 1 by 1
    	(if
    	  (member (strcase (vla-get-effectivename
    			     (vlax-ename->vla-object
    			       (setq sn (ssname ss (setq ii (1+ ii))))
    			     )
    			   )
    		  )
    		  VBlk
    	  )
    	   (block-analysis sn Tag)	; Analysis only for valid block names
    	)
          )
          (foreach nn *dd*
    	(setq pfx    (car (cdr (assoc (car nn) Bpfx)))
    	      nn     (cdr nn)
    	      nn     (vl-sort nn '(lambda (p1 p2) (< (car p1) (car p2))))
    					; Sort from small to large
    	      at     (mapcar 'reverse nn)
    	      SavStr (make-unique (mapcar 'car at))
    					; All existing valid label string
    	      SavDat (make-unique (mapcar 'cdr (mapcar 'cdr nn)))
    					; The (ValidHeight ValidString) data
    
    	)				; Format for nn ("BlockName" (HT1 AT1 SAVHT1 VALIDSTR1)(HT2 AT2 SAVHT2 VALIDSTR2)...)
    	(foreach at nn
    					; Format for mm (HTx ATx DATx)
    	  (setq	CalH (rtos (nth 0 at) 2 3) ; Calculated Height
    		SavH (nth 2 at)		; Saved Height
    		str  (nth 3 at)		; valid Attrribute Label, maybe not the same as the attribute's content
    		at   (nth 1 at)		; Attribute Object
    	  )
    	  (cond	((= CalH SavH)		; The Calculated height and Saved height is Same
    		 (setq xxx str)
    		)
    		((/= CalH SavH)		; The Calculated height and Saved height is not same, changed or new
    		 (if (null (setq xxx (cdr (assoc CalH SavDat))))
    		   (setq xxx	(strcat pfx (get-number SavStr pfx))
    			 SavStr	(cons xxx SavStr)
    			 SavDat	(cons (list CalH xxx) SavDat)
    					; Create new ID for new height
    		   )
    		   (setq xxx (car xxx))	; Using existing saved label with the proper height
    		 )
    		)
    	  )
    	  (vla-put-textstring at xxx)
    	  (vlax-ldata-put
    	    (vlax-vla-object->ename at)
    	    "GlassTag"
    	    CalH
    	  )
    	  (vlax-ldata-put
    	    (vlax-vla-object->ename at)
    	    "ValidTag"
    	    xxx
    	  )
    	)
          )
          (princ "done!")
        )
      )
      (princ)
    )
    
    (Defun C:JHUClearPartMark (/ block-clear BPFX II SN SS VBLK)
      (Defun block-clear (blk / at)
        (foreach at	(vlax-safearray->list
    		  (vlax-variant-value
    		    (vla-getattributes (vlax-ename->vla-object blk))
    		  )
    		)
          (if (vlax-ldata-get
    	    (setq at (vlax-vla-object->ename at))
    	    "GlassTag"
    	  )
    	(progn
    	  (vlax-ldata-delete at "GlassTag")
    	  (vlax-ldata-delete at "ValidTag")
    	)
          )
        )
      )
      (setq	Bpfx '(("450-CG-028 POCKET FILLER" "CPF")
    	       ("400-026 FLAT FILLER" "FF")
    	       ("400-075 CORNER POST" "CP")
    	       ("400-028 SILL FLASHING" "SF")
    	       ("450-CG-002 POCKET FILLER" "PF")
    	       ("400-011 TUBE HORIZONTAL" "H")
    	       ("400-003 SILL" "S")
    	       ("400-001 MULLION" "M")
    	       ("400-004 GLASS STOP" "GS")
    	      )
    	VBlk (mapcar 'car Bpfx)
    	ii   -1
      )
      (princ "\n Valid blocks:")
      (foreach ss VBlk
        (princ (strcat ss "\t"))
      )
      (princ "\n Please select the Glass block(s) <Exit>:")
      (if (setq ss (ssget (list (cons 0 "insert") (cons 66 1))))
        (progn
          (princ (strcat "\n Processing "
    		     (itoa (sslength ss))
    		     " pieces of glasses..."
    	     )
          )
          (repeat (sslength ss)
    	(if
    	  (member (strcase (vla-get-effectivename
    			     (vlax-ename->vla-object
    			       (setq sn (ssname ss (setq ii (1+ ii))))
    			     )
    			   )
    		  )
    		  VBlk
    	  )
    	   (block-clear sn)
    	)
          )
        )
      )
      (princ "done!\n")
      (princ)
    )
    Attached Files Attached Files

  3. #43
    Active Member
    Join Date
    2007-04
    Posts
    50
    Login to Give a bone
    0

    Default Re: Reference information from tables into blocks

    U need not try to make such modification on ur dynamic blocks, in fact, as u formerly just provide the DWG with glasses all stand there and can only be stretched along the Y direction, so the program ignore other situations such as u rotate the block for 90 or 270 degree and then u can stretch the glass in X direction. As what u want to gain i guess, it to let the program determine exactly the situation that if change on X or Y direction should be record.
    I have modifyed the sub function BLOCK-ANALYSIS, new function will go to see the rotation of block to determine if X direction change should be used. Use it to replace the old sub-function and try to see if you can get what u want.
    Code:
    (Defun block-analysis	(blk tagx / BN LL ROT SX SY UR XX YY)
        (vla-getboundingbox
          (setq blk (vlax-ename->vla-object blk))
          'll
          'ur
        )
        (setq bn (vla-get-effectivename blk)
    	  rot (vla-get-rotation blk)
    	  ll (vlax-safearray->list ll)
    	  ur (vlax-safearray->list ur)
    	  xx (abs (- (car ur) (car ll)))
    	  yy (abs (- (cadr ur) (cadr ll)))
        )
        (if(or (equal rot (* 0.5 pi) 0.001)
    	   (equal rot (* 1.5 pi) 0.001)
           )
          (setq yy xx)
        )      
        (foreach at	(vlax-safearray->list
    		  (vlax-variant-value (vla-getattributes blk))
    		)
          (setq sx (vlax-ldata-get (vlax-vla-object->ename at) "GlassTag")
    	    sy (vlax-ldata-get (vlax-vla-object->ename at) "ValidTag")
          )
          (if (member (vla-get-tagstring at) tagx) ; If the tag is valid
    	(if (null (setq xx (cdr (assoc bn *dd*))))
    	  (setq *dd* (cons (list bn (list yy at sx sy)) *dd*))
    					; New data, added directly
    	  (setq	xx   (cons (list yy at sx sy) xx)
    		*dd* (subst (cons bn xx) (assoc bn *dd*) *dd*)
    					; Existing data, update
    	  )
    	)
          )
        )
      )

  4. #44
    100 Club
    Join Date
    2006-11
    Location
    Martinsburg, WV USA
    Posts
    199
    Login to Give a bone
    0

    Default Re: Reference information from tables into blocks

    Quote Originally Posted by kozmosovia View Post
    U need not try to make such modification on ur dynamic blocks, in fact, as u formerly just provide the DWG with glasses all stand there and can only be stretched along the Y direction, so the program ignore other situations such as u rotate the block for 90 or 270 degree and then u can stretch the glass in X direction. As what u want to gain i guess, it to let the program determine exactly the situation that if change on X or Y direction should be record.
    I have modifyed the sub function BLOCK-ANALYSIS, new function will go to see the rotation of block to determine if X direction change should be used. Use it to replace the old sub-function and try to see if you can get what u want.
    Code:
    (Defun block-analysis	(blk tagx / BN LL ROT SX SY UR XX YY)
        (vla-getboundingbox
          (setq blk (vlax-ename->vla-object blk))
          'll
          'ur
        )
        (setq bn (vla-get-effectivename blk)
    	  rot (vla-get-rotation blk)
    	  ll (vlax-safearray->list ll)
    	  ur (vlax-safearray->list ur)
    	  xx (abs (- (car ur) (car ll)))
    	  yy (abs (- (cadr ur) (cadr ll)))
        )
        (if(or (equal rot (* 0.5 pi) 0.001)
    	   (equal rot (* 1.5 pi) 0.001)
           )
          (setq yy xx)
        )      
        (foreach at	(vlax-safearray->list
    		  (vlax-variant-value (vla-getattributes blk))
    		)
          (setq sx (vlax-ldata-get (vlax-vla-object->ename at) "GlassTag")
    	    sy (vlax-ldata-get (vlax-vla-object->ename at) "ValidTag")
          )
          (if (member (vla-get-tagstring at) tagx) ; If the tag is valid
    	(if (null (setq xx (cdr (assoc bn *dd*))))
    	  (setq *dd* (cons (list bn (list yy at sx sy)) *dd*))
    					; New data, added directly
    	  (setq	xx   (cons (list yy at sx sy) xx)
    		*dd* (subst (cons bn xx) (assoc bn *dd*) *dd*)
    					; Existing data, update
    	  )
    	)
          )
        )
      )
    that appears to have done the trick. Thank you very much!

  5. #45
    Member
    Join Date
    2008-05
    Posts
    5
    Login to Give a bone
    0

    Default Re: Reference information from tables into blocks

    Chris. Are you in Commercial glass or Residental. Per some of your drawings it appears that you are in the Commercial field. If so I am also in that same field. Commercial storefront and CurtainWall. Vistawall, U.S.aluminum, Cascade, etc... Maybe we can partner up and exchange templates and blocks to make our life easier when doing shop drawings or details etc... Let me know what you think. For glass sizes we use an excel sheet that automatically adds the correct measurment to our D.L.O dimension.

  6. #46
    Member
    Join Date
    2008-02
    Location
    North Seattle
    Posts
    42
    Login to Give a bone
    0

    Default Re: Reference information from tables into blocks

    Hello and great thread!

    I have been trying to get this code to work for me, but alas my knowledge is far below the programming going on here. I get the jist of it but cannot change the code to work with blocks I have created.

    I can get it to work with both original files, but was wondering if there is a way to make some changes?

    I propose the filter not be size but the location. i.e. from left to right, bottom to top.

    attached is a drawing that I would like to re-number the attributes.


    Any help in understanding what is going on here (programming wise) and how to make edits is HUGELY appreciated!
    Attached Files Attached Files

  7. #47
    Active Member
    Join Date
    2007-04
    Posts
    50
    Login to Give a bone
    0

    Default Re: Reference information from tables into blocks

    Try the program
    Code:
    (Defun c:test (/ block-analysis ii ss sn dd data at p1 p2 val chk tag)
      (Defun block-analysis	(blk bname / att dat x v)
        (if
          (and (setq blk (vlax-ename->vla-object blk))
    	   (= bname (vla-get-effectivename blk))
    	   (equal (vlax-get-property blk "IsDynamicBlock") :vlax-true)
    	   (setq att (car (vlax-safearray->list
    			    (vlax-variant-value (vla-getattributes blk))
    			  )
    		     )
    	   )
          )
           (setq dat (vl-remove-if
    		   'null
    		   (mapcar
    		     '(lambda (x)
    			(if (setq v (vlax-variant-value (vla-get-value x)))
    			  (cons	(vla-get-propertyname x)
    				(if (= (type v) 'safearray)
    				  (vlax-safearray->list v)
    				  v
    				)
    			  )
    			)
    		      )
    		     (vlax-safearray->list
    		       (vlax-variant-value
    			 (vla-getdynamicblockproperties blk)
    		       )
    		     )
    		   )
    		 )
    	     x	 (vlax-safearray->list
    		   (vlax-variant-value (vla-get-insertionpoint blk))
    		 )
    	     dat (list (car x)
    		       (cadr x)
    		       (strcat (rtos (abs (cdr (assoc "Distance" dat))) 2 4)
    			       "#"
    			       (rtos (abs (cdr (assoc "Distance1" dat))) 2 4)
    		       )
    		       att
    		 )
           )
        )
        dat
      )
      (vl-load-com)
      (if (and (setq ii -1
    		 ss (princ "\n Please select block(s) <Exit>:")
    		 ss (ssget (list (cons 0 "insert")
    				 (cons 66 1)
    			   )
    		    )
    	   )
          )
        (progn
          (repeat (sslength ss)
    	(setq sn (ssname ss (setq ii (1+ ii))))
    	(if (setq dd (block-analysis sn "2400 ACM PANEL 1"))
    	  (setq data (cons dd data))
    	)
          )
          (setq ii 99
    	    data
    	     (vl-sort
    	       data
    	       '(lambda	(p1 p2)
    		  (if (/= (car p1) (car p2))
    		    (< (car p1) (car p2))
    		    (if	(/= (cadr p1) (cadr p2))
    		      (< (cadr p1) (cadr p2))
    		      (< (nth 2 p1)
    			 (nth 2 p2)
    		      )
    		    )
    		  )
    		)
    	     )
          )
          (foreach at data
    	(setq tag (nth 2 at)
    	      at  (last at)
    	)
    	(if (null (setq val (cdr (assoc tag chk))))
    	  (setq	ii  (1+ ii)
    		val (strcat "A" (itoa ii))
    		chk (cons (cons tag val) chk)
    	  )
    	)
    	(vla-put-textstring at val)
          )
        )
      )
    )
    Last edited by kozmosovia; 2008-05-21 at 03:11 PM.

  8. #48
    Member
    Join Date
    2008-02
    Location
    North Seattle
    Posts
    42
    Login to Give a bone
    0

    Default Re: Reference information from tables into blocks

    Quote Originally Posted by kozmosovia View Post
    Try the program
    Code:
    (Defun c:test (/ block-analysis ii ss sn dd data at p1 p2 val chk tag)
      (Defun block-analysis	(blk bname / att dat x v)
        (if
          (and (setq blk (vlax-ename->vla-object blk))
    	   (= bname (vla-get-effectivename blk))
    	   (equal (vlax-get-property blk "IsDynamicBlock") :vlax-true)
    	   (setq att (car (vlax-safearray->list
    			    (vlax-variant-value (vla-getattributes blk))
    			  )
    		     )
    	   )
          )
           (setq dat (vl-remove-if
    		   'null
    		   (mapcar
    		     '(lambda (x)
    			(if (setq v (vlax-variant-value (vla-get-value x)))
    			  (cons	(vla-get-propertyname x)
    				(if (= (type v) 'safearray)
    				  (vlax-safearray->list v)
    				  v
    				)
    			  )
    			)
    		      )
    		     (vlax-safearray->list
    		       (vlax-variant-value
    			 (vla-getdynamicblockproperties blk)
    		       )
    		     )
    		   )
    		 )
    	     x	 (vlax-safearray->list
    		   (vlax-variant-value (vla-get-insertionpoint blk))
    		 )
    	     dat (list (car x)
    		       (cadr x)
    		       (strcat (rtos (abs (cdr (assoc "Distance" dat))) 2 4)
    			       "#"
    			       (rtos (abs (cdr (assoc "Distance1" dat))) 2 4)
    		       )
    		       att
    		 )
           )
        )
        dat
      )
    
      (if (and (setq ii -1
    		 ss (princ "\n Please select block(s) <Exit>:")
    		 ss (ssget (list (cons 0 "insert")
    				 (cons 66 1)
    			   )
    		    )
    	   )
          )
        (progn
          (repeat (sslength ss)
    	(setq sn (ssname ss (setq ii (1+ ii))))
    	(if (setq dd (block-analysis sn "2400 ACM PANEL 1"))
    	  (setq data (cons dd data))
    	)
          )
          (setq ii 99
    	    data
    	     (vl-sort
    	       data
    	       '(lambda	(p1 p2)
    		  (if (/= (car p1) (car p2))
    		    (< (car p1) (car p2))
    		    (if	(/= (cadr p1) (cadr p2))
    		      (< (cadr p1) (cadr p2))
    		      (< (nth 2 p1)
    			 (nth 2 p2)
    		      )
    		    )
    		  )
    		)
    	     )
          )
          (foreach at data
    	(setq tag (nth 2 at)
    	      at  (last at)
    	)
    	(if (null (setq val (cdr (assoc tag chk))))
    	  (setq	ii  (1+ ii)
    		val (strcat "A" (itoa ii))
    		chk (cons (cons tag val) chk)
    	  )
    	)
    	(vla-put-textstring at val)
          )
        )
      )
    )

    I get "error: no function definition: VLAX-ENAME->VLA-OBJECT" when I run the program.
    Is there something in the code that I need to change to be specific to my blocks?

  9. #49
    Active Member
    Join Date
    2007-04
    Posts
    50
    Login to Give a bone
    0

    Default Re: Reference information from tables into blocks

    I forget to add (vl-load-com) and have changed the code in the original post, please try it again.

  10. #50
    Member
    Join Date
    2008-02
    Location
    North Seattle
    Posts
    42
    Login to Give a bone
    0

    Default Re: Reference information from tables into blocks

    OK!

    That worked awsome!

    A couple thing I might need help with though. If I want to use it with multiple blocks, to I change this line

    Code:
       (progn
          (repeat (sslength ss)
    	(setq sn (ssname ss (setq ii (1+ ii))))
    	(if (setq dd (block-analysis sn "2400 ACM PANEL 1"))
    	  (setq data (cons dd data))
    to look like this?

    Code:
       (progn
          (repeat (sslength ss)
    	(setq sn (ssname ss (setq ii (1+ ii))))
    	(if (setq dd (block-analysis sn "2400 ACM PANEL 1"))
    	(if (setq dd (block-analysis sn "whatever"))
    	(if (setq dd (block-analysis sn "whatever2"))
    	  (setq data (cons dd data))
    I have many different variations of the same block with different names.

    Also, where could I (How could I) ad a pause for user input for the "A" in the attribute to be anything the user wants. We use "A-Z" for the first part of label.

    I am really trying to learn as much as possible so as not to "glom" code off of everybody. Thank you for your valuable time!

    Last edited by Opie; 2008-05-27 at 01:49 PM. Reason: [CODE] tags added, see Moderator Note

Page 5 of 7 FirstFirst 1234567 LastLast

Similar Threads

  1. View Reference information disappearing
    By MTristram in forum Revit Architecture - General
    Replies: 0
    Last Post: 2008-10-23, 02:48 AM
  2. cross reference tables and blocks in both directions
    By james.126519 in forum API Wish List
    Replies: 0
    Last Post: 2008-02-29, 01:48 PM
  3. Reference text between tables
    By rb773 in forum AutoCAD Tables
    Replies: 1
    Last Post: 2007-11-12, 09:42 PM
  4. Excel Information Into Tables
    By CADdancer in forum AutoCAD Tables
    Replies: 4
    Last Post: 2007-08-03, 03:56 PM
  5. Blocks, Databases and Tables
    By WeirdOne in forum AutoCAD Map 3D - General
    Replies: 14
    Last Post: 2006-04-19, 06:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •