Results 1 to 3 of 3

Thread: If statement w/ attribute tags.

  1. #1
    I could stop if I wanted to
    Join Date
    2009-04
    Location
    Houston, TX
    Posts
    204
    Login to Give a bone
    0

    Default If statement w/ attribute tags.

    I am working with some code from another lisp, (credit Jeffrey Sanders), and I am wanting it to do something if it comes across blocks containing attributes w/ tag "model#". So far I have gotten two results, syntax error, or my computer locked up until I close autocad via task mgr. (think routine was caught in a loop), although I don't have the copy where it locked up.

    The overall picture for this routine would be to get these models and the numbers associated w/ them (in the fields), run some calcs, and put it in table format inside autocad, however this is just the first step, I'm new to LISP.

    I thought about just getting the data and exporting it to Excel into a template already set up, but so far it looks like it would be easier to keep it all in autocad.

    I've looked around on the lisp forums through numerous posts but it hasn't clicked with me, so here I am! Here is the drawing and block I am testing with.

    Oh, side note. I work with DB's, and if anyone can offer insight on how to get the real name of the block, not *U##, through lisp, I have been playing with that as well. The latest I have read about, but not played with yet, is getting it via properties as the real name is listed there, or vla-get-effective name??
    Attached Files Attached Files

  2. #2
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    0

    Default Re: If statement w/ attribute tags.

    An equivalent of your code in vla
    Code:
    (vl-load-com)
    ((lambda ( / js nbr result_att ent_name ename id_obj)
    	(setq
    		js (ssget "_X" '((0 . "INSERT") (8 . "FA") (2 . "`*U*")))
    		nbr -1
    		result_att nil
    	)
    	(cond
    		(js
    			(repeat (sslength js)
    				(setq
    					ent_name (ssname js (setq nbr (1+ nbr)))
    					ename (vlax-ename->vla-object ent_name)
    					id_obj (vla-get-ObjectName ename)
    				)
    				(if (eq id_obj "AcDbBlockReference")
    					(foreach n (vlax-invoke ename 'GetAttributes)
    						(if (eq (vlax-get n 'TagString) "MODEL#")
    							(setq result_att (cons (vlax-get n 'TextString) result_att))
    						)
    					)
    				)
    			)
    		)
    	)
    	result_att
    ))

  3. #3
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: If statement w/ attribute tags.

    If you're using 2008 (or later), why don't you simply use DataExtraction? It could generate such table for you, which would then be possible to update with a single click. Even the earlier Attribute Extraction could do something similar.

    See the attached created with Vanilla 2008's DataExtraction command. The DXE file's the definition & the Table in the DWG can be updated using the DataLinkUpdate command (which is available on the DataLink icon in right of status bar). Not to mention that a pop-up notification happens if AC notices that the data might have changed (similar to XRef notifications).

    Extract both files to the same folder. Open the DWG and erase / copy some of the blocks. Change the attrib value. Save & type DataLinkUpdate, follow the prompts to Update Link (and select the table) or Update all Data Links in one go. Or (depending on your settings - DXEVAL) a pop-up should show after the save happens.
    Attached Files Attached Files
    Last edited by irneb; 2009-11-17 at 05:17 AM.

Similar Threads

  1. 2013: Xrefs and Attribute tags
    By gjh in forum AutoCAD LT - General
    Replies: 2
    Last Post: 2014-05-10, 09:49 PM
  2. Renaming Attribute Tags?
    By rkingery in forum AutoLISP
    Replies: 25
    Last Post: 2013-01-09, 01:19 PM
  3. Deleting Duplicate Attribute Tags
    By bustr0giantcatfish974410 in forum AutoCAD Customization
    Replies: 0
    Last Post: 2012-03-28, 01:47 PM
  4. Attribute Tags
    By RobertAitken in forum VBA/COM Interop
    Replies: 5
    Last Post: 2010-06-11, 11:01 AM
  5. Re-use attribute tags
    By nancy.beulens in forum AutoCAD General
    Replies: 8
    Last Post: 2009-12-29, 03:23 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
  •