DSmith2300 Posted July 25, 2024 Share Posted July 25, 2024 Hello! I have thousands of shapefiles that have been imported into a blank file with lots of lovely data behind them, but they all come in on class 'NONE'. I also have lots of lovely classes that are similarly named by importing a legend from another file. I would love some advice about this script I've part made using the Custom Selection tool. SelectObj(((L='EPI_Land_Zoning') & (R IN ['EPI_Land_ZoningRec']) & ('EPI_Land_ZoningRec'.'SYM_CODE'=''))); Where it says'SYM_CODE'='', I'd like to be able to enter a field value. Like C1, or EP3, or whatever, so I can then grab all the things using that data and put them into the correct class, with the correct fill (by class). This is instead of having to go through the Custom Selection drop downs 100+ times and to choose the same things over and over again, with the last value being different of course. My brain doesn't do code. I started looking at the VS language guides and my eyes began to bleed. I'm a visual guy not a code/ math person. Could someone who understands these wizardly ways please tell me what arcane jibber-jabber to chant, to allow a variable to be entered each time I activate the script? Many thanks! Quote Link to comment
DSmith2300 Posted July 25, 2024 Author Share Posted July 25, 2024 I've realised I've overcomplicated things, and can cut even quicker to the chase but still need a variable entry function: Is this possible? thanks Quote Link to comment
DSmith2300 Posted July 25, 2024 Author Share Posted July 25, 2024 LOL. I feel like I'm using a screwdriver as a hammer, but I figured out a quickish similar way to get the job done. I created a basic script to do the above which named a value. I keep editing it to change the value then running it, changing the class as nesc. Then rinse and repeat. It works but it's an ugly, method. Better than fiddling with the drop downs a hundred times. Quote Link to comment
Pat Stanford Posted July 25, 2024 Share Posted July 25, 2024 Are you done? Or would a script still be helpful? Are the Code and the desired Class Name the same? If so it will be quite easy. Quote Link to comment
DSmith2300 Posted July 25, 2024 Author Share Posted July 25, 2024 Quote Are you done? Or would a script still be helpful? Are the Code and the desired Class Name the same? If so it will be quite easy. Thanks Pat. I am basically done for the moment, but will need to do similar in the future. Any help or scripting advice would still be greatly appreciated! Unfortunately the class isn't named exactly like the code, but I'm sure with a mass class name change that could be fixed pretty quickly. cheers. Quote Link to comment
Pat Stanford Posted July 25, 2024 Share Posted July 25, 2024 How about a script to place all the objects in a class that has a name that matches their Sym_Code. Then you could go though and delete those classes and pick the class to move the objects in that class to. Or if there is a naming structure that would "easily" allow the generation of the correct class name from the Sym_Code we could use that. Just to make sure I am using the correct record and field names, can you post a file with a couple of your shape objects with different Sym_Codes and the include the names of the classes those Sym_Codes should link to. Quote Link to comment
DSmith2300 Posted July 26, 2024 Author Share Posted July 26, 2024 Thanks Pat! I've attached a snippet of the file and put it back to how it used to be, more or less. All the shapes (polylines / polygons) are back on the NONE class, like they originally came in. Correct classes are present but the names are formatted by the preface "ZONING-" The zoning code in the data record is the field: SYM_CODE. BTW it was not originally the #1 field but I fiddled with the order according to another post about scripts while trying to labelled them all. I've also posted a query in the DATA TAGS forum topic about how to tag these all. But that's another story. Thanks for your help! RE-CLASS TEST FOR PAT..vwx Quote Link to comment
Pat Stanford Posted July 26, 2024 Share Posted July 26, 2024 Here is a script that will take every object with the record and set it's class to ZONING- plus the SYM_CODE. If the class does not exist it will create it. If it does exist it will (should) use it. Procedure ShapeZoneToClass; VAR S1 :String; Procedure Execute(Hd1:Handle); BEGIN S1:=Concat('ZONING-',GetRField(Hd1,'EPI_Land_ZoningRec','SYM_CODE')); SetClass(Hd1,S1); End; BEGIN ForEachObject(Execute,((R IN ['EPI_Land_ZoningRec']))); End; RUN(ShapeZoneToClass); Short version of what this does. ForEachObject passes each object with the record to the Execute procedure. Execute makes a string out of 'ZONING' & the SYM_CODE and then set the Class of the object to that string. HTH. 1 Quote Link to comment
DSmith2300 Posted July 26, 2024 Author Share Posted July 26, 2024 (edited) Wow! Thanks Pat! I'll give it a whirl shortly. That stuff is totally beyond my capabilities, but I can see how I could likely modify the class / sources in the future for other projects. Edit: Worked like a charm! Edited July 26, 2024 by DSmith2300 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.