Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Combining multiple unique value text strings from attribute definitions into one separate attribute definition value

10 REPLIES 10
Reply
Message 1 of 11
sarahsarah2015
725 Views, 10 Replies

Combining multiple unique value text strings from attribute definitions into one separate attribute definition value

Hello all.

 

 I am wondering how to combine multiple unique value text strings from attribute definitions into one separate attribute definition value. I also want it to update automatically (or use a command to sync it all at once but "attsync" doesn’t seem to do the trick) For example: I want the unique value of "" , "", and "" values to be combined text with spaces on the "" line.

 

I have included below what I have already tried but can't get it to update atomatically correctly:  

 

 

I am trying to get this block "x GROUP" to update as "x x x" automatically

 

Each value will be different so a "find and replace" or update in properties tab wont work.

I have included a DWG with an example block with data and original inserted block. 

 

Thank you in advance for your time and help.

Labels (4)
10 REPLIES 10
Message 2 of 11
ronjonp
in reply to: sarahsarah2015

Like this ? You'll need to regen to see the changes. AFAIK you cannot link the default values within the attribute definitions. It has to point back to the attributes within the block to get the actual text 'values'.

Message 3 of 11
sarahsarah2015
in reply to: ronjonp

**** EDIT THIS DID NOT WORK ***

 

 

Message 4 of 11
sarahsarah2015
in reply to: ronjonp

Wait when I go to redefine the block it changes "Block Reference" to "Block" and doesnt work. Could you tell me how to redefine the block instead of just changing the "Las Vegas" block.

Message 5 of 11
ronjonp
in reply to: sarahsarah2015


@sarahsarah2015 wrote:

Wait when I go to redefine the block it changes "Block Reference" to "Block" and doesnt work. Could you tell me how to redefine the block instead of just changing the "Las Vegas" block.


Why are you trying to redefine the block?

 

Give this code a try .. it will populate all existing "ADDRESS_DATA" blocks with the correct fields.

(defun c:foo (/ _fld a b c d s)
  ;; RJP » 2023-05-04
  (defun _fld (id) (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa id) ">%,1).TextString>%"))
  (cond	((setq s (ssget "_X" '((0 . "INSERT") (2 . "ADDRESS_DATA"))))
	 (foreach e (mapcar 'cadr (ssnamex s))
	   (foreach at (vlax-invoke (vlax-ename->vla-object e) 'getattributes)
	     (cond ((= "AP#" (vla-get-tagstring at)) (setq a at))
		   ((= "APSIZE" (vla-get-tagstring at)) (setq b at))
		   ((= "TAILFT" (vla-get-tagstring at)) (setq c at))
		   ((= "APGROUP" (vla-get-tagstring at)) (setq d at))
	     )
	   )
	   (vla-put-textstring
	     d
	     (strcat (_fld (vla-get-objectid a))
		     " "
		     (_fld (vla-get-objectid b))
		     " "
		     (_fld (vla-get-objectid c))
	     )
	   )
	 )
	)
  )
  (princ)
)

 

Message 6 of 11
sarahsarah2015
in reply to: ronjonp

I need hundreds of these blocks to be imported at once (using mapimport and a address shapefile). So I have to redefine the block I think. The intention is to automatically have this field setup to generate on import. 

Message 7 of 11
ronjonp
in reply to: sarahsarah2015

@sarahsarah2015 

If you're importing them and the blockname matches your example as well as the attributes then run my code once after the import and all should be good. 

 

I don't use MAP so not sure what this import looks like.

Message 8 of 11
sarahsarah2015
in reply to: ronjonp

I can do that for my current project but this is intended for a n is for this to work on import. Thank you for the script it's just not what I am looking for unfortunately. If you have any insight into how to create the block to be formatted like the example block you did any hints are welcomed! 

Message 9 of 11
ronjonp
in reply to: sarahsarah2015

@sarahsarah2015 

A hack would to use that block I made which is correct .. then insert it into your drawing .. explode it then do whatever map import specializes in.

Message 10 of 11
sarahsarah2015
in reply to: ronjonp

but you didn't redefine the block which is what I need to do first in order to insert the block again. You edited the individual example block but when I redefine the block you made it doesn't automatically update the field. That is what the original purpose of the post is.  

Message 11 of 11
ronjonp
in reply to: sarahsarah2015

@sarahsarah2015 

I told you much earlier in this thread that you cannot link the default values to attribute definitions. The block I "fixed" is referencing itself ( block reference ) and the attributes ( not attribute definitions ) within it that contain values. 

 

Long story short, AFAIK what you're trying to do is not possible. Use the code I provided .. it's better than nothing. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report