Jump to content

Set Symbol Z position


Recommended Posts

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

Link to comment

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 by MullinRJ
  • 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...