MarcelP102 Posted October 1, 2022 Share Posted October 1, 2022 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. Quote Link to comment
Pat Stanford Posted October 1, 2022 Share Posted October 1, 2022 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); Quote Link to comment
MarcelP102 Posted October 1, 2022 Author Share Posted October 1, 2022 Fantastic, thanks! I will give it a try tomorrow. Quote Link to comment
MarcelP102 Posted October 2, 2022 Author Share Posted October 2, 2022 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! 2 Quote Link to comment
MullinRJ Posted October 3, 2022 Share Posted October 3, 2022 @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 Quote Link to comment
Recommended Posts
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.