Jump to content
  • 0

Delete all annotations in selected viewports


NicoleD

Question

Is there a command to be able to delete all annotations from all viewports on a page, or from all viewports selected? I tend to duplicate sheet layers but then have to go back and delete dimensions and callouts from each viewport one by one. It would be very helpful and a time saver to be able to do it all at once.

Link to comment

13 answers to this question

Recommended Posts

  • 0
  • Marionette Maven

@NicoleD

I wrote a Python script that will delete all objects from the annotations group of selected VPs. This script will also only work on the active Layer (either sheet or design, though DLVPs do not have an annotation group).

The script is undoable in case you make a mistake, but it is always recommended to test this in a copy file.

The script is located in Palette-1.

DeleteAnnoObjs.vwx

  • Like 3
Link to comment
  • 0
1 hour ago, Marissa Farrell said:

@NicoleD

I wrote a Python script that will delete all objects from the annotations group of selected VPs. This script will also only work on the active Layer (either sheet or design).

The script is undoable in case you make a mistake, but it is always recommended to test this in a copy file.

The script is located in Palette-1.

DeleteAnnoObjs.vwx

 

This is really cool. I'd be curious to know how I could modify it to omit certain objects (delete everything except the drawing labels for example).

 

Kevin

 

Link to comment
  • 0
  • Marionette Maven

The following script will leave out Drawing Labels if they only have the default records added to them, which is how they are inserted by default. Extra logic would need to be added in order to check if multiple records are attached to the drawing labels.

 

#Created by MFarrell 12/05/18
#Modified to exclude Drawing Labels

#collect handles of selected VPs on active layer
def GetHandle(h):
	if vs.GetTypeN(h) == 122:
		if vs.GetParent(h) == vs.ActLayer():
			hVP.append(h)
			
hVP = []
vs.ForEachObject( GetHandle, '(Sel = True)' )

#Traverse into the annotations group of selected VPs and delete all objects aside from Default DLs
for VP in hVP:
	anno = vs.GetVPGroup(VP, 2)
	h = vs.FInGroup(anno)
	objs = [h]
	h = vs.NextObj(h)
	while h != vs.Handle(0):
		#recs = vs.NumRecords(h)
		if str(vs.GetName(vs.GetRecord(h, 1))) != 'Drawing Label':
			objs.append(h)
		h = vs.NextObj(h)
	for obj in objs:
		vs.DelObject(obj)

 

  • Like 2
Link to comment
  • 0
On 12/5/2018 at 11:40 AM, Marissa Farrell said:

The following script will leave out Drawing Labels if they only have the default records added to them, which is how they are inserted by default. Extra logic would need to be added in order to check if multiple records are attached to the drawing labels.

Marissa:

I understand why you collected the handles of the Viewports before processing the actions but I was wondering why you collected the handles of the drawing labels before not deleting them.  Would it be more efficient code to delete objects as you detect them?

 

 

Edited by The Hamma
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...