English

How To: Scale points in a 3D Analyst Scene

Summary

Point symbols do not scale in a 3D Scene. The following script will create a 3D polygon based on your points that when zoomed into will get scale appropriately.

Procedure

1. Create a new script window.

A. Activate the Project window.
B. Click the Scripts icon.
C. Click New.

2. Paste the following code into the new window.

Code:
'-- This script will extract points from the selected features of a
'-- polygon/polyline theme at specified intervals and convert them to
'-- a new point theme...
'
'-- Initialize variables
v = av.getactivedoc
themes = v.getthemes

'-- Create list of themes to choose from
thmlist = list.make

for each thm in themes
if (thm.is(ftheme)) then
c = thm.getftab.getshapeclass.getclassname
if ((c="point") or (c="pointz")) then
thmlist.add(thm)
end
end
end
t = msgbox.list(thmlist,"What theme?","")
if (t = nil) then exit end '-- If point themes is chosen, select Z field
theftab = t.getftab
if (theftab.getshapeclass.getclassname = "point") then
noz = true
flist = list.make
for each fld in theftab.getfields
if (fld.istypenumber) then
flist.add(fld)
end
end
zfield = msgbox.list(flist,"Choose the Z field or click cancel"+nl+ "to apply a z value of 0 to every point","")
else
noz = false
end

'-- Get legend info to scale symbols
l = t.getlegend
'msgbox.info(l.getlegendtype.asstring,"")

asym= FALSE
if (l.getlegendtype=#legend_type_symbol) then
asym = TRUE
thefieldcount = l.getfieldnames.count
if (thefieldcount > 0) then
if (l.getnormtype = #LEGEND_NORMTYPE_NONE) then
NCF = 1
thefield1 = theftab.findfield(l.getfieldnames.get(0))
'msgbox.info(l.getfieldnames.get(0),ncf.asstring)
elseif (l.getnormtype = #LEGEND_NORMTYPE_FIELD) then
NCF = 2
thefield2 = theftab.findfield(l.getnormfieldname)
thefield1 = theftab.findfield(l.getfieldnames.get(0))
'msgbox.info(thefield2.getname ++ thefield1.getname,ncf.asstring)
end
end
slist = list.make
for each s in l.getsymbols
slist.add(s.getsize)
' msgbox.info(s.getsize.asstring,"symbol size")
end
themed = (slist.get(0)+slist.get(slist.count-2))/2
'msgbox.info(themed.asstring,"The median symbol")
end
sfield = theftab.findfield("shape")
thescale = t.returnextent.getwidth*0.05
accept = msgbox.yesno("The default size is "+(thescale*2).asstring+nl+"Accept value?" ,"",true)
if (accept.not) then
thescale2 = msgbox.input("please specify the default size","",(thescale*2).asstring)
if ((thescale2 = NIL) or (thescale2.isnumber.not)) then
return nil
exit
else
thescale = (thescale2.asnumber)/2
end
end

'-- Create multipatch theme
'msgbox.info(n.asstring,"")
defaultName = FN.Make("$HOME").MakeTmp("theme","shp")
newfile = FileDialog.Put(defaultName,"*.shp","New Multipatch Theme")
if (newfile = nil) then exit end
thenewftab = ftab.makenew(newfile,multipatch)
thenewtheme = ftheme.make(thenewftab)
newfldShape = thenewFTab.FindField("Shape")
for each afld in theFTab.getfields.clone
if(afld.getname = "Shape") then continue end
thenewftab.addfields({afld.clone})
end

'-- Select the multipatch shape style
theoutshape = msgbox.listasstring({"3D dohickey","Cube","Pyramid","Diamond"},
"Choose the 3d shape","Point to Multipatch")
if (theoutshape = nil) then exit end
ones2do = theftab.getselection
if (ones2do.count = 0) then
ones2do = theftab
thecount = ones2do.getnumrecords
else
thecount = ones2do.count
end

av.showstopbutton
'-- Begin loop thru FTAB
if (thenewftab.starteditingwithrecovery) then
for each rec in ones2do
keepgoing = av.setstatus ((rec/thecount)*100)
if (keepgoing.not) then
return nil
exit
end
ptz = theftab.returnvalue(sfield,rec)
x = ptz.getx
y = ptz.gety
if (noz) then
if (zfield = nil) then
z = 0
else
z = theftab.returnvalue(zfield,rec)
end
else
z = ptz.getz
end
'-- Apply legend scaling
anum = 0
if (asym) then
for each cls in l.getclassifications
if (ncf = 1) then
lval = theftab.returnvalue(thefield1, rec)
elseif (ncf = 2) then
lval = (theftab.returnvalue(thefield1,
rec)/theftab.returnvalue(thefield2, rec))
end
if (cls.contains(lval)) then
n = thescale*(slist.get(anum)/themed)
break break
msgbox.info("rec = "+rec.asstring++"n value = "+n.asstring,"")
else
'msgbox.info(cls.getminimum++lval.asstring++cls.maximum++"didn't work","")
end
anum = anum + 1
end
else
n=thescale
end
'-- Make the multipatch shape
if (theoutshape = "3d dohickey") then
newshape = multipatch.make({{
{(x-n)@(y-n)@z, (x+n)@(y-n)@z, (x+n)@(y+n)@z, (x-n)@(y+n)@z},
{(x-n)@y@(z-n), (x+n)@y@(z-n), (x+n)@y@(z+n), (x-n)@y@(z+n)},
{x@(y-n)@(z-n), x@(y+n)@(z-n), x@(y+n)@(z+n), x@(y-n)@(z+n)}},
{#PART_TYPE_OUTERRING, #PART_TYPE_OUTERRING,
#PART_TYPE_OUTERRING}})
elseif (theoutshape = "cube") then
newshape = multipatch.make({{
{(x-n)@(y-n)@(z+n), (x+n)@(y-n)@(z+n), (x+n)@(y+n)@(z+n),
(x-n)@(y+n)@(z+n)},
{(x-n)@(y-n)@(z-n), (x+n)@(y-n)@(z-n), (x+n)@(y+n)@(z-n),
(x-n)@(y+n)@(z-n)},
{(x-n)@(y+n)@(z-n), (x+n)@(y+n)@(z-n), (x+n)@(y+n)@(z+n),
(x-n)@(y+n)@(z+n)},
{(x-n)@(y-n)@(z-n), (x+n)@(y-n)@(z-n), (x+n)@(y-n)@(z+n),
(x-n)@(y-n)@(z+n)},
{(x+n)@(y-n)@(z-n), (x+n)@(y+n)@(z-n), (x+n)@(y+n)@(z+n),
(x+n)@(y-n)@(z+n)},
{(x-n)@(y-n)@(z-n), (x-n)@(y+n)@(z-n), (x-n)@(y+n)@(z+n),
(x-n)@(y-n)@(z+n)}},
{#PART_TYPE_OUTERRING, #PART_TYPE_OUTERRING,
#PART_TYPE_OUTERRING,
#PART_TYPE_OUTERRING, #PART_TYPE_OUTERRING,
#PART_TYPE_OUTERRING}})
elseif (theoutshape = "pyramid") then
newshape = multipatch.make({{
{(x-n)@(y-n)@(z-n), (x+n)@(y-n)@(z-n), (x+n)@(y+n)@(z-n),
(x-n)@(y+n)@(z-n)},
{(x-n)@(y+n)@(z-n), (x+n)@(y+n)@(z-n), x@y@(z+n)},
{(x-n)@(y-n)@(z-n), (x+n)@(y-n)@(z-n), x@y@(z+n)},
{(x+n)@(y-n)@(z-n), (x+n)@(y+n)@(z-n), x@y@(z+n)},
{(x-n)@(y-n)@(z-n), (x-n)@(y+n)@(z-n), x@y@(z+n)}},
{#PART_TYPE_OUTERRING, #PART_TYPE_OUTERRING,
#PART_TYPE_OUTERRING,
#PART_TYPE_OUTERRING, # PART_TYPE_OUTERRING}})
elseif (theoutshape = "Diamond") then
newshape = multipatch.make({{
{(x-n)@(y+n)@(z), (x+n)@(y+n)@(z), x@y@(z+n)},
{(x-n)@(y-n)@(z), (x+n)@(y-n)@(z), x@y@(z+n)},
{(x+n)@(y-n)@(z), (x+n)@(y+n)@(z), x@y@(z+n)},
{(x-n)@(y-n)@(z), (x-n)@(y+n)@(z), x@y@(z+n)},
{(x-n)@(y+n)@(z), (x+n)@(y+n)@(z), x@y@(z-n)},
{(x-n)@(y-n)@(z), (x+n)@(y-n)@(z), x@y@(z-n)},
{(x+n)@(y-n)@(z), (x+n)@(y+n)@(z), x@y@(z-n)},
{(x-n)@(y-n)@(z), (x-n)@(y+n)@(z), x@y@(z-n)}},
{#PART_TYPE_OUTERRING, #PART_TYPE_OUTERRING,
#PART_TYPE_OUTERRING,
#PART_TYPE_OUTERRING, #PART_TYPE_OUTERRING,
#PART_TYPE_OUTERRING,
#PART_TYPE_OUTERRING}})
'
'-- Add record and assign attributes
end
newrec = thenewftab.addrecord
thenewftab.setvalue(newfldshape,newrec,newshape)
for each afld in theFtab.getfields
if(afld.getname = "Shape") then continue end
newval = theFtab.returnvalue(afld,rec)
thenewftab.setvalue(thenewftab.findfield(afld.getalias),newrec,newval)
end
end
end
thenewftab.stopeditingwithrecovery(true)
v.addtheme(thenewtheme)
v.invalidate
av.purgeobjects
msgbox.info ("done","")

3. Select Compile from the Script menu.

4. Make the 3D Scene with the point theme active.

5. Click directly on the script window.

6. Click the Run
[O-Image] Run compiled script button
button. Follow the instructions on the Wizard.