Select to view content in your preferred language

How to change a layer's symbology using VBscript

2243
2
Jump to solution
05-15-2013 08:42 PM
DanikBourdeau
Deactivated User
I can't seem to figure out how to manipulate a layers symbology using VBscript.  In my code below I'm creating a new polyline shapefile and then adding it to the map (along with a new feature).  I want to set a specific colour for this layer, how would I go about doing so?

Set TrackRS = CreateAppObject("recordset") lnShape = Preferences.Properties("DataPath") & "\TracksShape\TrackLog" & TrackDte & ".shp" TrackRS.Create lnShape, 3, Application.Map.CoordinateSystem TrackRS.Fields.Append "Length", 5  Set TrackShape = Map.AddLayerFromFile(lnShape) If TrackShape Is Nothing then exit sub TrackShape.Editable = true TrackShape.Records.AddNew ln TrackShape.Records.Update  Map.Extent = TrackShape.Extent Map.Refresh True


Thanks,
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
ThaiTruong
Deactivated User
Looks like you need to create a layer definition file (apl), name it to the same name with the shapefile, and write it to the same location with the shapefile.  It's just a simple XML file like this:

<ArcPad>  <LAYER>   <SYMBOLOGY>    <SIMPLERENDERER>     <SIMPLELINESYMBOL width='1' color='blue'/>    </SIMPLERENDERER>   </SYMBOLOGY>   <SYSTEMOBJECTS/>  </LAYER> </ArcPad>


You need to create this XML file before adding the layer to your map (Set TrackShape = Map.AddLayerFromFile(lnShape))

Hope this helps!

View solution in original post

0 Kudos
2 Replies
ThaiTruong
Deactivated User
Looks like you need to create a layer definition file (apl), name it to the same name with the shapefile, and write it to the same location with the shapefile.  It's just a simple XML file like this:

<ArcPad>  <LAYER>   <SYMBOLOGY>    <SIMPLERENDERER>     <SIMPLELINESYMBOL width='1' color='blue'/>    </SIMPLERENDERER>   </SYMBOLOGY>   <SYSTEMOBJECTS/>  </LAYER> </ArcPad>


You need to create this XML file before adding the layer to your map (Set TrackShape = Map.AddLayerFromFile(lnShape))

Hope this helps!
0 Kudos
DanikBourdeau
Deactivated User
Thanks Thai,  I figured it had something to do with that.

I do find it strange though, that I can't manipulate the symbology of a layer directly through the Map object.  I guess what I'll do is create a bunch of dummy apl's and keep them stored on the devices, then whenever I need one I'll just copy and rename it.

Thanks again.
0 Kudos