Jump to content

Vectorscript help for a non-coding dummy.


Recommended Posts

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!

 

Link to comment

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.

Link to comment
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.

Link to comment

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.

Link to comment

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

Link to comment

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.

  • Like 1
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...