Jump to content
Developer Wiki and Function Reference Links ×

Delete specific records from file


Recommended Posts

Hi, After using the ArcGIS feature service to bring in georeferenced shapes I'm getting a lot of records making the file size grow. Also all new created objects will automatically get the records of the ArcGIS feature until I disable the georeference of that layer.

 

That's why I want to make a script to delete the records. They are in the root of my resource browser. I think I need to use the DeleteResourceFromList command, is this correct? I don't really understand the example of the wiki.

 

Any help would be appreciated.

 

image.png.d5b77a0831b0eb36fd36b9cbf3128d1a.png

Link to comment

Hi Marcel, 

 

Are you using VS or Python?

 

DeleteResouceFromList will only remove it from the resource list you are working with. It will not remove it from the VW Document. For that you need to use DelObect.

 

Here is the outline of a VS version.  Not tested, but the basic Idea.  Make sure you test on a dummy file or backup.

 

Procedure DelRecordFormats;

Var		L1,L2, L3		:LongInt;
		S1				:String;

Begin
	L1:=BuildResourceList(47,0,'',L2);
	For L3:=1 to L2 do
		Begin
			S1:=GetActualNameFromResourceList(L1,L3);
			If SubString(S1,'_',1)='ESRI' then
				DelObject(GetObjectFromList(L1, L3);
		End;
End;

Run(DelRecordFormats);

 

Link to comment
Procedure DelRecordFormats;

Var		L1,L2, L3		:LongInt;
		S1				:String;

Begin
	L1:=BuildResourceList(47,0,'',L2);
	For L3:=1 to L2 do
		Begin
			S1:=GetActualNameFromResourceList(L1,L3);
			If SubString(S1,'_',1)='ESRI' then 	DelObject(GetResourceFromList(L1, L3));
		End;
End;

Run(DelRecordFormats);

 

The script worked with a small modification, thanks again!

  • Like 2
Link to comment

@MarcelP102,

   You can also use the Pos() function to test the string. I'm not sure which one is faster. If you have enough records to delete you can test the two commands against each other and see if there is a noticeable difference. But if your list of records is small, it doesn't matter which way you go; they'll both be fast enough. The benefit is you'll know which function to use if you know you have a large set of records to process someday. My guess is Pos() will be faster than SubString(), but by how much  🤔  ?!?

 

If (SubString(S1, '_', 1) = 'ESRI') then DelObject(GetResourceFromList(L1, L3));

vs.

If (Pos('ESRI_', S1) = 1) then DelObject(GetResourceFromList(L1, L3));

 

You only need to check if you are interested. But if you do check, I'd love to hear your result.

 

Raymond

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
Reply to this topic...

×   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...