AttSync not working in a script file

AttSync not working in a script file

Anonymous
Not applicable
2,807 Views
8 Replies
Message 1 of 9

AttSync not working in a script file

Anonymous
Not applicable

I'm at the point in a script where I want to sync the block named temptitle then purge the block named  4title.  The script snipit looks like:

 

ATTSYNC Name "temptitle" -Purge B "4title" N

 

When the script runs up to that point, it tries to use everything after the Name option as the block name:

 

Command: ATTSYNC
Enter an option [?/Name/Select] <Select>: Name
Enter name of block to sync or [?]: "temptitle" -Purge B "4title" N -Rename B "temptitle" "4title" Qsave Close
Block table contains no attributed block named "temptitle" -Purge B "4title" N -Rename B "temptitle" "4title" Qsave Close

 

I've tried it with and without the "" around the name and with an extra space after the block name.

 

Any suggestion on how to make the script read the name properly?

 

Thanks,

 

Jon

0 Likes
Accepted solutions (1)
2,808 Views
8 Replies
Replies (8)
Message 2 of 9

cadffm
Consultant
Consultant
Your little mistake. You must confirm the block name with an ENTER, which is a line break.
In the script, insert a line break immediately after the last character of the block name.

Space is not equal to enter!
Autocad interprets a space as Enter only in situations where no space is allowed.
Try it by hand in the command line. -Attsync space / works because there can be no command-name with spaces.

Name spaces as well.

Then type the block name and leave spaces and other input, blanks are allowed in block names (unfortunately).

Hope it helps.

Sebastian

Message 3 of 9

Ranjit_Singh
Advisor
Advisor

Does adding on separate lines help. Like this

ATTSYNC
Name
temptitle
-Purge
B
4title
N etc. etc.

0 Likes
Message 4 of 9

Anonymous
Not applicable

Hi Betreff,

 

Spaces as returns work elsewhere in the script such as:

 

    -blockreplace "4title" "temptitle" N Erase L  

 

Those all work fine with spaces as Enters but not here:

 

   ATTSYNC Name "temptitle" -Purge B 

 

I've tried using a "" as an Enter but that didn't help.

I don't know what you mean by "
"Name spaces as well" 

 

Any other suggestions?

0 Likes
Message 5 of 9

Anonymous
Not applicable

Thanks Ranjit,

 

This script applies to about 400 files an would be a bit unwieldy with that many extra line breaks.

 

Any other suggestions?

 

 

0 Likes
Message 6 of 9

cadffm
Consultant
Consultant

"Space is not equal to enter!
Autocad interprets a space as Enter only in situations where no space is allowed.
Try it by hand in the command line. -Attsync space / works because there can be no command-name with spaces."

 

This works for me (, but should not! I do not know why autoCAD accepts a space to confirm the blockname in the Purge-command /-in Scripts)

_.ATTSYNC _name temptitle
_.-PURGE _block 4title _no

 

Normally, the block name should also be confirmed with a line break in the Clean Up dialog.

_.ATTSYNC _name temptitle
_.-PURGE _block 4title
_no

Sebastian

0 Likes
Message 7 of 9

Anonymous
Not applicable
Accepted solution

It's solved.  I had to enter the text as a LISP command:

 

    Erase L  (command "ATTSYNC" "Name" "temptitle") -Purge B 

 

Thanks for everyone's input.

Message 8 of 9

bgumPXZJF
Advocate
Advocate

I was having issue with my lisp not finishing when I used my script generator.

Below is the lisp code that I got to work when used in script generator. It was odd cause I had no issues in a single drawing when ran as just lisp 

Below that are 2 lines that are generated from my script generator.

 

Has to do with the line return as mentioned about by CADffm, i solved this by just adding a blank "(command)" after attsync. Hope this helps. 

;===========================================================
; 9/Jun/2021 10:24 AM[Wednesday]	AUTHOR: Brandon Gum
;--
;----WORKING---
;DESCRIPTION: Replace a block definition over a list of drawings. Designed to be used with ScriptPro. 
;We will use the CoreConsole within Script Pro.
;--
;The insert portion needs a = after the block name to let it know that you are trying to redeclare from external source.
;--
;Had issues with this in script format with it not continuing on. 
;SOLVED! ---> Attysnc was cause. See details below. Logged in onenote.
;--
;Thought it has to do with attsync and or active viewport.
;Ended up being because of attsync. 
;Saw a post online that said you needed a line-return after specifing the block name to confirm it. Just added a "(command)" afterwards.
;------------
;HELPFUL LINK =;https://www.cad-notes.com/how-to-update-autocad-block-in-multiple-files-using-script/
;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/best-practice-modifying-block-definitions/td-p/8902280
;===========================================================
;-INSERT
;"O:\Veolia Technical Solutions\13004.330 Gum Springs\Dwgs\_Plant 3D\Constructs\Veolia E-size PID Border Text"
(defun C:BlockRedefine ( / )
	(command "attreq" "0") ;added as precaution
	(if (= (getvar 'tilemode) 0) ;if already in paperspace
		(progn
			(command "._PSPACE") ;disable active viewport as a precaution
		);_end of progn
	);_end of if 		
	(if (tblsearch "block" "Veolia E-size P3D Border Text")
		(progn
			(command "-rename" "b" "Veolia E-size P3D Border Text" "Veolia E-size PID Border Text")
			(command "insert" "Veolia E-size PID Border Text=O:\\Veolia Technical Solutions\\13004.330 Gum Springs\\Dwgs\\_Plant 3D\\Constructs\\Veolia E-size PID Border Text" nil)
			(command "_.attsync" "n" "Veolia E-size PID Border Text")
			(command) ;needed to get the lisp to work when ran with bg_scr_generator. It would stop and not save then close. However it would continue to work if I typed resume.
			(while (= 1 (getvar 'cmdactive)) ;wait for cmd to finish as a precaution. Was having issues with script not continuing.
				(command pause) ;added as precaution
			) ;end of while
		) ;_end of progn
	) ;_end of if
	(command "attreq" "1") ;added as precaution
	(princ) ;quiet close
) ;end of function 

 

_.open "O:\Veolia Technical Solutions\13004.330 Gum Springs\Dwgs\_Plant 3D\Dwgs_Gum Springs\PID DWG\VGS-PRO-0100-PID-8770.dwg" (setvar "filedia" 0) (load "blockredefine" nil) (C:blockredefine) _.qsave
_.close
_.open "O:\Veolia Technical Solutions\13004.330 Gum Springs\Dwgs\_Plant 3D\Dwgs_Gum Springs\PID DWG\VGS-PRO-0100-PID-8771.dwg" (setvar "filedia" 0) (load "blockredefine" nil) (C:blockredefine) _.qsave
_.close
0 Likes
Message 9 of 9

bgumPXZJF
Advocate
Advocate

Had to make one small change. Was still unstable. Ultimately it is a work around. I cant figure out why this is failing and causing script to pause. 

 

Got around it by using: (command resume)

I confirmed that it was the attsync causing the script to fail. Never found a way to debug the script execution to see what errors were being thrown to cause the issue. 

0 Likes