Page 1 of 3 123 LastLast
Results 1 to 10 of 29

Thread: linking field data to other object data

  1. #1
    Member
    Join Date
    2006-03
    Posts
    30
    Login to Give a bone
    0

    Default linking field data to other object data

    I would like to have a routine to link my most current rev (in a block called rev_block) to my title block. So basically when I create a new rev, it automatically updates my title block. The following routine works to recreate this link when it's broken on a 32 bit system:

    (setq fld-a
    (strcat "%<\\AcObjProp Object(%<\\_ObjId "
    (rtos objid-A 2 0)
    ">%).TextString \\f \"%tc1\">%"
    )
    )

    I now have a 64 bit system and this code will not work. Any ideas? Here's my current code I'm trying to run, but it won't work. I'm not sure what's going on.

    (setq fld-rev "%<\\AcObjProp Object(%<\_ObjId 8796087924336>%).TextString \\f \"%%tc1\">%")

    Thanks!

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: linking field data to other object data

    What is objid-A?

  3. #3
    Member
    Join Date
    2006-03
    Posts
    30
    Login to Give a bone
    0

    Default Re: linking field data to other object data

    (setq objid-A (vla-get-objectid(vlax-ename->vla-object en-A)))

    The vla command will not run in 64 bit system. Sorry I didn't see this in my initial post.

  4. #4
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: linking field data to other object data

    Quote Originally Posted by keith_velishek View Post
    (setq objid-A (vla-get-objectid(vlax-ename->vla-object en-A)))

    The vla command will not run in 64 bit system. Sorry I didn't see this in my initial post.
    VBA will not run in 64 bit system, no problem with visual lisp. See the Sticky at the top of the Lisp Forum:
    http://forums.augi.com/showthread.ph...up-(vla-)-code
    I use 11 routines on a regular basis on a 64 bit system that use vla-get-objectid Have you tried adding (vl-load-com) to Acaddoc.lsp or anywhere before you use vla commands?
    If you post the code that worked for you before we should be able to figure out why it's not working anymore.

  5. #5
    Member
    Join Date
    2006-03
    Posts
    30
    Login to Give a bone
    0

    Default Re: linking field data to other object data

    Here's the code that I use when running in a 32 bit Windows XP system. This code does not work when running in windows 7 64 bit.



    Code:
    (vl-load-com)
    
    (defun c:14rlk ()
    
    	(command "pspace")
    
    	(command "zoom" "extents")
    
    	(setq CurrLayr (getvar "clayer"))
    
    	(setq CurrOsmode (getvar "osmode"))
    
    	(command "osmode" "0")
    
    	(setq tb-name "14_TBLOCK-D")
    					;..............	ids TBLOCK vintage
    	(setq ss1 (ssget "_C" '(19.3125 0.4375) '(19.75 0.3125)))
    					;..............	ids positionally specific rev block
    	(setq en (ssname ss1 0))
    					;..............	gets ent name
    	(setq en-A (entnext en))
    					;..............	gets letter-number ent info
    	(setq en-desc (entnext en-A))
    					;..............	gets descr ent info					
    	(setq en-date (entnext en-desc))
    					;..............	gets date ent info	
    	(setq en-by (entnext en-date))
    					;..............	gets by ent info	
    	(setq en-appr (entnext en-by))
    					;..............	gets appr ent info	
    	(setq objid-A (vla-get-objectid(vlax-ename->vla-object en-A)))
    	
    	(setq objid-date (vla-get-objectid(vlax-ename->vla-object en-date)))
    	
    	(setq objid-desc (vla-get-objectid(vlax-ename->vla-object en-desc)))
    	
    	(setq objid-by (vla-get-objectid(vlax-ename->vla-object en-by)))
    	
    	(setq objid-appr (vla-get-objectid(vlax-ename->vla-object en-appr)))
    	
    	(setq fld-a
    		(strcat "%<\\AcObjProp Object(%<\\_ObjId "
    			(rtos objid-A 2 0)
    			">%).TextString \\f \"%tc1\">%"
    		)
    	)
    	
    	(setq fld-date
    		(strcat "%<\\AcObjProp Object(%<\\_ObjId "
    			(rtos objid-date 2 0)
    			">%).TextString \\f \"%tc1\">%"
    		)
    	)
    	
    	(setq fld-desc
    		(strcat "%<\\AcObjProp Object(%<\\_ObjId "
    			(rtos objid-desc 2 0)
    			">%).TextString \\f \"%tc1\">%"
    		)
    	)
    		
    	(setq fld-by
    		(strcat "%<\\AcObjProp Object(%<\\_ObjId "
    			(rtos objid-by 2 0)
    			">%).TextString \\f \"%tc1\">%"
    		)
    	)
    	
    	(setq fld-appr
    		(strcat "%<\\AcObjProp Object(%<\\_ObjId "
    			(rtos objid-appr 2 0)
    			">%).TextString \\f \"%tc1\">%"
    		)
    	)
    	
    	(setq fld-drwgname "%<\\AcVar Filename \\f \"%tc4%fn2\">%")
    						;......	Creates FIELD code for drawing name
    	
    	(command "-bedit" tb-name)
    
    	(command "-layer" "set" "X_BORDER-TXT" "")
    
    	(setq er1 (ssget "_C" '(25.6875 -0.15625) '(26.875 -0.9375)))
    
    		(if er1
    
    			(command "erase" er1 "")
    
    		);...if
    
    	(setq er2 (ssget "_C" '(34.25 1.0625) '(34.875 0.46875)))
    
    		(if er2
    
    			(command "erase" er2 "")
    
    		);...if
    
    	(setq er3 (ssget "_C" '(33.0 0.25) '(33.5 0.125)))
    
    		(if er3
    
    			(command "erase" er3 "")
    
    		);...if
    
    	(command "-style" "A100" "Arial" "0.100" "1" "0" "N" "N")
    			
    	(command "AFLAGS" "19")
    			
    	(command "-attdef" "" "REV_DESC" fld-desc "style" "A100" "justify" "BL" "26,-0.28125" "0")
    			
    	(command "-attdef" "" "REV_BY" fld-by "style" "A100" "justify" "BL" "26,-0.53125" "0")
    			
    	(command "-attdef" "" "REV_DATE" fld-date "style" "A100" "justify" "BL" "26,-0.78125" "0")
    			
    	(command "-attdef" "" "REV_APPR" fld-appr "style" "A100" "justify" "BL" "26,-1.03125" "0")
    			
    	(command "-style" "A445-BLOCK_USE_ONLY" "Arial" "0.445" "1" "0" "N" "N")
    			
    	(command "AFLAGS" "18")
    
    	(command "-style" "A130" "Arial" "0.130" "1" "0" "N" "N")
    
    	(command "-attdef" "" "DRAWING_NUMBER" fld-drwgname "style" "A130" "justify" "mL" "32.875,0.125" "0")
    			
    	(command "-attdef" "" "REV" fld-a "style" "A445-BLOCK_USE_ONLY" "justify" "MC" "34.4375,0.8125" "0")
    		
    	(command "chprop" "all" "" "color" "bylayer" "")	
    			
    	(command "_bsave")
    			
    	(command "_bclose")
    			
    	(repeat 3 (command "-purge" "all" "" "n"))
    
    	(command "osmode" CurrOsmode)
    
    	(command "-style" "A100" "Arial" "0.100" "1" "0" "N" "N")
    
    	(if (= (wcmatch CurrLayr "X*") T)
    
    		(command "layer" "set" "0" "")	
    
    		(command "layer" "set" CurrLayr "")
    
    	);...if
    			
    );...defun
    Last edited by Opie; 2014-03-20 at 03:50 PM. Reason: [code] tags added for clarity

  6. #6
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: linking field data to other object data

    Can you elaborate on "will not work"? Do you get an error message? You use a lot of command calls in there, should be a lot of output. Could you copy and paste the output here? I don't have "14_TBLOCK-D" you're going to have to let us know what it's not doing for you.

  7. #7
    Member
    Join Date
    2006-03
    Posts
    30
    Login to Give a bone
    0

    Default Re: linking field data to other object data

    the routine grabs the attributes in 14_revblock and inserts it into 14_tblock-d, however it will not create a field in 64 bit. I've attached everything you need in this dwg. You'll notice if you update the rev and refresh the title block will automatically update as well. After running this code in 64 bit system, it will update, but won't be a field.
    Attached Files Attached Files

  8. #8
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: linking field data to other object data

    Have a look at the bit of code in this post. The util variable in that code is referring to the Utility property of the current drawing. So, you will need to provide access to that property for it to extract the string value of the objectid of various objects.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  9. #9
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: linking field data to other object data

    I believe the command prompts may have changed from your old version. Enter "-attdef" at the command line and follow the prompts. I was able to create the attribute, but needed to
    Enter attribute prompt: "name"
    before I could
    Enter default attribute value: %<\AcVar Filename \f "%tc4%fn2">%
    Code:
     (command "-attdef" "" "DRAWING_NUMBER" "name" fld-drwgname "A130" "justify" "mL" "32.875,0.125" "0")
    HTH

  10. #10
    Member
    Join Date
    2006-03
    Posts
    30
    Login to Give a bone
    0

    Default Re: linking field data to other object data

    Here's the error I get when adding "name" in. It actually doesn't have a problem creating the drawing number field, I suspect it's because it's not a field linked to another block attribute. It's just linked to the filename. I'm having trouble with the other 6 fields I'm trying to create. Thanks for your help!

    Command: -attdef
    Current attribute modes:
    Invisible=Y Constant=Y Verify=N Preset=N Lock position=Y Annotative=N Multiple line=N
    Enter an option to change [Invisible/Constant/Verify/Preset/Lock position/Annotative/Multiple lines] <done>:
    Enter attribute tag name: REV_DESC
    Enter attribute value: name
    Current text style: "A100" Text height: 0.10000000 Justify: Left
    Specify start point of text or [Justify/Style]: %<\AcObjProp Object(%<\_ObjId 44>%).TextString \f "%tc1">%
    Point or option keyword required.
    ; error: Function cancelled
    Specify start point of text or [Justify/Style]: *Cancel*

Page 1 of 3 123 LastLast

Similar Threads

  1. 2014: Added object data fields to Polyline, but object data is empty or zero
    By tntdraftsol in forum AutoCAD Map 3D - General
    Replies: 6
    Last Post: 2015-07-24, 12:20 PM
  2. block with linking field data when inserted
    By cjharley1450642179 in forum AutoLISP
    Replies: 3
    Last Post: 2014-04-22, 04:41 PM
  3. LINKING OBJECT DATA TO TABLES
    By knickers in forum AutoCAD Tables
    Replies: 3
    Last Post: 2009-08-10, 08:09 PM
  4. Linking AutoCAD Object data directly to Excel
    By Shizzjr in forum AutoCAD General
    Replies: 4
    Last Post: 2007-04-10, 08:17 PM
  5. Apply line object data field to linetype?
    By bhaugi in forum AutoCAD Map 3D - General
    Replies: 4
    Last Post: 2006-10-08, 02:20 AM

Posting Permissions

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