Jump to content

Send to surface


Sloader

Recommended Posts

The send to surface command fails when I run it with a large number of polygons so I was hoping to loop though all my polygons using a script.

The script below is my attempt but it doesn't make anything happen.  

 

dtmL=vs.GetObject('XX-ZZ-M-U-LiDAR_DTM')
hdtm=vs.DTM6_GetDTMObject(dtmL,True)

def SendSurface(h):
	vs.DTM6_SendToSurface(hdtm, h, 0)

vs.ForEachObject(SendSurface, "L=XX-ZZ-P-G-OS_MasterMap Fills-3D-2" )

 

Link to comment

I think it might be that you need single quotes around the layer name in the Criteria string of the ForEachObject procedure.

 

"L='XX-ZZ-P-G-OS_MasterMap Fills-3D-2'"

 

Vectrorscript also seems to like parentheses around criteria.

 

"((L='XX-ZZ-P-G-OS_MasterMap Fills-3D-2'))"

 

 

That is double quotes around the entire string and single quotes around just the layer name.

 

If that does not work then try something simpler. Select just a couple of objects and use a criteria like SEL

 

""((SEL=True))"

 

That should help you prove that the rest of the code works or if the problem is somewhere else.

 

Or use the Criteria Builder in the built in Script Editor to generate the correct criteria string instead of trying to type it manually.

 

HTH

  • Like 2
Link to comment
3 hours ago, Pat Stanford said:

Or use the Criteria Builder in the built in Script Editor to generate the correct criteria string instead of trying to type it manually.

^^ This method never fails.

Just make sure to set your language in the script editor appropriately 

Edited by twk
Link to comment
""((SEL=True))"

  Doesn't work 

 

 

"((SEL=True))"

  Does work 

 

 

"((L='XX-ZZ-P-G-OS_MasterMap Fills-3D-2'))"

 Does work 

 

 

((L='XX-ZZ-P-G-OS_MasterMap Fills-3D-2')) From the criteria builder doesn't work (language is set to python) - I write the criteria by hand as the builder has never worked and was one of the issues that really slowed me down when first trying to write scripts. If I wrap it in double quotes it does work 

"((L='XX-ZZ-P-G-OS_MasterMap Fills-3D-2'))"

 

I can see why my original criteria didn't work, though I was following a previous example that did work - "T=LOCUS"

 

 

 

Link to comment

The explanation is that the criteria builder creates a string, but you need the quotes around that string to put a string constant into the ForEachObject procedure.

 

The L= criteria also requires a string for the layer name which is why you need the single quotes.

 

T=LOCUS should only require a single set of quotes as both the the T and LOCUS are defined terms and not Vectorscript strings.

 

And you are lucky you are working in Python which allows both single and double quotes.  In Vectorscript you can only use single quotes and you either have to use the correct incantation of multiple single quotes to "escape" the interior quotes or some other form of work around such as defining a single quote as a constant (or variable) and then using that along with a Concat to build the criteria string.

 

Finally, ForEachObject (and the other ForEach functions) don't like the use of variables as part of a criteria string. The solution for that is to make a single variable that contains the entire criteria string and then pass that single variable as the criteria for the procedure/function.

 

So (Sorry for the Vectorscript nomenclature, but I hope it gives you this idea.)

 

MyLayer := 'Design Layer-1';

MyCriteria := Concat('((T=LOCUS) & (L=', MyLayer,'))');

ForEachObject(Execute, MyCriteria);

 

HTH

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