Search for: KB10331 - Create a polygon or other shape programmatically. Question from a customer: "Relating to my farming application I am using the DK to develop, I have difficulty making a shape (polygon) programmatically and introducing it into LayerSHP. My code is as follows: Create Layer: lb := TGIS_LayerVector.Create ; lb.Name := 'buffer' ; lb.AddField('Query',gisFieldTypeString,20,0); lb.AddField('Min',gisFieldTypeNumber,3,0); GIS.ADD( lb ) ; Create Shape: ... from a buffer ... Add shape: if Assigned( shp ) then begin shp.Params.Area.Color := ZonasCol[i].Color; shp.Params.Area.OutlineWidth := 1; shp.Params.Area.OutlineColor := clBlack; shp.Params.Area.Pattern := bsSolid; lb.AddShape(shp); lb.Shape.SetField('Query', q); // <- Error!! lb.Shape.SetField('Min',ZonasCol[i].LimiteInf); // <- Error!! end; //buf But I cannot SetField! What is wrong?" Answer: Operate on the shape itself, not lbShape (which can be undefined outside MoveFirst..MoveNext loop). The following code should help: lb.AddShape(shp); shp.SetField('Query', q); shp.SetField('Min',ZonasCol[i].LimiteInf); // <- Error!! end; //buf Created: November 21, 2003, Modified: August 06, 2015