Sloader Posted March 14, 2022 Share Posted March 14, 2022 I have the script below which places, scales and rotates tree symbols based on a set of 2d Loci created in GIS. I would like to set the Z position of the symbols based on an attribute but can't get it to work. I am trying to use Move3D as below but no joy. def ReplaceRAND1s(h):#Function to replace all loci from imported shapefile with scaled canopy symbols rand=vs.GetRField(h, 'TreePointsForSymbolsRec','RAND_COLOU')#Get the random colour for the canopy loci sym= vs.Concat('Canopy-'+ rand)#Convert the colour code to canopy symbol name ScaleX=vs.GetRField(h, 'TreePointsForSymbolsRec','RAD')#Get scale from loci record ScaleY=vs.GetRField(h, 'TreePointsForSymbolsRec','RAD')#Get scale from loci record ScaleZ=vs.GetRField(h, 'TreePointsForSymbolsRec','rvalue_1')#Get tree height from loci record AOD=vs.GetRField(h, 'TreePointsForSymbolsRec','DTM_1')#Get AOD height from loci record X, Y = vs.GetLocPt(h)#Get location from loci to place symbol randrot= vs.Random()*100 #create a random number to rotate the symbol by vs.Symbol(sym, X, Y, randrot) # place symbol based on loci postion, random colour and random rotation vs.Move3D(0, 0, AOD) h2 = vs.LNewObj() # get handle to new symbol instance vs.SetObjectVariableInt(h2, 101, 3) #Set symbol scaling to asymetric vs.SetObjectVariableReal(h2, 102, ScaleX)#Set X scale vs.SetObjectVariableReal(h2, 103, ScaleY)#Set Y scale vs.SetObjectVariableReal(h2, 104, ScaleZ)#Set Z scale/ height vs.DelObject(h)#clean up loci vs.ForEachObject(ReplaceRAND1s, ("T=LOCUS")) #loop for all the loci in the file TreeLoci.vwx Quote Link to comment
MullinRJ Posted March 14, 2022 Share Posted March 14, 2022 (edited) Try using: vs.Move3DObj(vs.LNewObj(), 0, 0, AOD) instead. This moves the symbol by referencing its handle, and vs.LNewObj() returns a handle to the last object created in the drawing – "usually". Raymond PS - After actually reading your code, move the "move symbol" line after you assign variable h2. Then it should look like this: h2 = vs.LNewObj() vs.Move3DObj(h2, 0, 0, AOD) vs.SetObjectVariableInt(h2, 101, 3) #Set symbol scaling to assymetric ... Edited March 14, 2022 by MullinRJ 1 Quote Link to comment
Sloader Posted March 17, 2022 Author Share Posted March 17, 2022 Move3DObj does work, many thanks. I see its listed right by Move3D in the Function reference and I still didn't spot it. I also seem to be missing something about how to use the search tool in the procedures dialogue within VW. 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.