|
POST
|
We're almost there, here's the output <</T(Member1)/V(Member1Jon P)>> <</T(Member2)/V(Member2Arnold G)>> <</T(Member3)/V(Member3Art F)>> <</T(Member4)/V(Member4Pete H)>> I don't need the member1Jon P just Jon P in the second part.
... View more
07-31-2012
02:03 PM
|
0
|
0
|
2490
|
|
POST
|
Thanks so much for all your help today, I'll give this a shot shortly. I'm not really sure exactly what's going on in this loop. Any chance you have time to explain this code? I'd rather learn why this works than blindly copy/paste to resolve my immediate need. Thanks again Jon
... View more
07-31-2012
01:52 PM
|
0
|
0
|
2490
|
|
POST
|
Sorry for being unclear. As I mentioned, ultimately I'm writing values to an FDF file, which will be used in conjunction with a PDF template. The PDF contains fields for each Member, there can be up to 9 members. The fields are named Member1, Member2, etc. through Member9. The line of code that writes the values out is this. Using the field name in the PDF/FDF, and the data from the script
txt.write("<</T(FDF Field Name)/V(" + str(arcpy variable name) + ")>>\n")
[\code]
I have potentially 9 team members, but not always. I may have none or some, not always 9.
I'm trying to write these values in a loop. So something like this
Loop through the members list
create a variable for each item in the list
populate that variable with the value from the list
write that variableto the FDF file using txt.write
so the loop would actually contain the txt.write
for item in lMembers:
FDF_Field_Name = FDF_Field_Name+item
FDF_Field_Name+item = lmembers+string_value
txt.write("<</T(FDF_Field_Name)/V(" + str(FDF_Field_Name+item) + ")>>\n")
arcpy.AddMessage(item)
something like that, probably clear as mud now ;) Cheers
... View more
07-31-2012
11:47 AM
|
0
|
0
|
2490
|
|
POST
|
Ah ha! So if I'd like to increment wMembers to wMembers+item_Number and another to wMemberName+Item_value
item = None
for item in lMembers:
wMembers+item_number = item
wMewmberName+Value_of_lMember
so i'd end up with wMembers1 containing value Jon P wmembers2 containing value Arnold G wMember3 containing value Pete H etc How would i manage that? Thanks again
... View more
07-31-2012
10:50 AM
|
0
|
0
|
2490
|
|
POST
|
Yes the names populate correctly. The reason the list 'could' be empty is if there are no people in that Team yet. The team name woudl exist in the teams table by has no members at this time, so i need to account for that. I'm very new to Python (like a week) and I'm unaware of dictionaries, which is why I didn't use them 🙂 Thanks for the other tips. [ATTACH=CONFIG]16519[/ATTACH] I've attached the run screen as a screenshot
... View more
07-31-2012
10:30 AM
|
0
|
0
|
2490
|
|
POST
|
Ok thanks, here goes. Note that I haven't written code to write out the lMembers info yet.
#arcpy.env.workspace = workspc
arcpy.env.overwriteOutput = "True"
from arcpy import env
# Pull data from Incident_Information FC
fc1="Incident_Information"
rows = arcpy.SearchCursor(fc1)
row = rows.next()
arcpy.AddMessage(fc1)
while row:
# Loop through rowns and pull incident name from Incident_Name field
Incident_Name = row.getValue("Incident_Name")
arcpy.AddMessage("while loop 1")
row = rows.next()
del rows
del row
# Loops through the Assignmets table and read field values to vars
fc2="Assignments"
rows = arcpy.SearchCursor(fc2)
arcpy.AddMessage(fc2)
row = rows.next()
# Pull data from the Assignments feature class aVar from Assignments
while row:
arcpy.AddMessage("Get Assignment Information")
aAssign = row.getValue("Assignments.Assignment_Number")
aDesc = row.getValue("Assignments.Description")
aMiles = row.getValue("Assignments.Mileage")
aInsertion = row.getValue("Assignments.Insertion")
aStatus = row.getValue("Assignments.Status")
aOpPeriod = row.getValue("Assignments.Period")
aTeam = row.getValue("Assignments.Team_Name")
# Pull data from Op Period FC using Period number
arcpy.AddMessage("Matching Operation Period")
fc4 = "Operation_Period"
rowPeriod = arcpy.SearchCursor(fc4, "Period = " + str(aOpPeriod))
# loops through operation periods and reads values into vars based on Op number pVar for Period
for x in rowPeriod:
pWeather = x.getValue("Weather")
pSafety = x.getValue("Safety_Message")
pFreqP = x.getValue("Primary_Comms")
pFreqE = x.getValue("Emergency_Comms")
pPlans = x.getValue("Planning_Chief")
del x
# Pull data from Teams FC using Assignment Number building quesry in var qTeam
arcpy.AddMessage("Matching Teams")
fc5 = "Teams"
qTeam = '"Team_Name"' + "='" + str(aTeam) + "'"
arcpy.AddMessage(qTeam)
rowPeriod = arcpy.SearchCursor(fc5,qTeam)
# loops through Teams and reads values into vars based on Team name tVar for Team
for y in rowPeriod:
tType = y.getValue("Team_Type")
tCallSign = y.getValue("radio_Call_Sign")
tLeader = y.getValue("Leader")
del y
del rowPeriod
# Pull data from Team Members FC using Team Name building query in mVar
arcpy.AddMessage("Matching Team Members")
fc6 = "Team_Members"
qTeam = '"Team_Name"' + "='" + str(aTeam) + "'"
arcpy.AddMessage(qTeam)
rowMembers = arcpy.SearchCursor(fc6,qTeam)
lMembers = []
# loops through Teams and reads values into list lMembers. List = lVar
z = 0
for z in rowMembers:
mName = z.getValue("Name")
lMembers.append(mName)
arcpy.AddMessage(mName)
del z
del rowMembers
arcpy.AddMessage("Building Assignment Number " + str(aAssign))
# Create new fdf file
filename = output + "/" + str(aAssign) + ".fdf"
txt= open (filename, "w")
txt.write("%FDF-1.2\n")
txt.write("%????\n")
txt.write("1 0 obj<</FDF<</F(ICS-204.pdf)/Fields 2 0 R>>>>\n")
txt.write("endobj\n")
txt.write("2 0 obj[\n")
txt.write ("\n")
# Write field names to FDF file
txt.write("<</T(incident_name)/V(" + str(Incident_Name) + ")>>\n")
txt.write("<</T(assignment_number)/V(" + str(aAssign) + ")>>\n")
txt.write("<</T(operational_period)/V(" + str(aOpPeriod) + ")>>\n")
txt.write("<</T(asgn_description)/V(" + str(aDesc) + ")>>\n")
txt.write("<</T(resource_type)/V(" + str(tType) + ")>>\n")
txt.write("<</T(asgn.description)/V(" + str(aDesc) + ")>>\n")
txt.write("<</T(.size_of_assignment)/V(" + str(aMiles) + ")>>\n")
txt.write("<</T(transport_instructions)/V(" + str(aInsertion) + ")>>\n")
txt.write("<</T(radio_call)/V(" + str(tCallSign) + ")>>\n")
txt.write("<</T(freq_command)/V(" + str(pFreqP) + ")>>\n")
txt.write("<</T(freq_command)/V(" + str(pFreqE) + ")>>\n")
txt.write("<</T(prepared_by)/V(" + str(pPlans) + ")>>\n")
txt.write("<</T(notes)/V(" + str(pWeather) + ")>>\n")
# Write Team Members to FDF file from list lMembers
for item in lMembers:
wMembers = item
arcpy.AddMessage(item)
del item
# Close and write FDF file
txt.write("]\n")
txt.write("endobj\n")
txt.write("trailer\n")
txt.write("<</Root 1 0 R>>\n")
txt.write("%%EO\n")
txt.close ()
row = rows.next()
del rows
del row
I very much appreciate your help Thanks Jon
... View more
07-31-2012
09:51 AM
|
2
|
0
|
2212
|
|
POST
|
I can do the FDF part (let me know if you're interested in how that works. if I try the following, I receive this error. <type 'exceptions.NameError'>: name 'item' is not defined
for item in lMembers:
wMembers = item
arcpy.AddMessage(item)
lMembers is a list of peoples names, the number of folks vary. I need to write these names to variables to build my FDF file. So i actually need two variables creates, one for the variable name and one containing the persons name. I thought I'd simplify my question by just asking how to pull the name value from the list. In the end I'm looking to get something like this variable item+numeric number for item (this would be the variable field placeholder, so 1, 2, 3, 4, etc) variable name+ value for item (this is the string value from the lMembers, Jon, Steve, Amy, etc.) the code will look somewhat like that, that writes the files
txt.write("<</T(item)/V(" + str(name) + ")>>\n")
... View more
07-31-2012
09:33 AM
|
0
|
0
|
2212
|
|
POST
|
Here's a better explanation The list lMembers contains values such as [jon, pete, paul, steve, etc] when I iterate that list later I want to pull the values from this list and write them to an output, building an FDF file. The code is attempting to do the following
loop for as many times as there are items in the list
for each list item, write that value to a output variable that can then be written out
... View more
07-31-2012
09:05 AM
|
0
|
0
|
2212
|
|
POST
|
Morning, I'm receiving this error when running a For loop "list indices must be integers". Could this be because my list is of stype string? Here's the code. First I write values to list lMembers rowMembers = arcpy.SearchCursor(fc6,qTeam) lMembers = [] for z in rowMembers: mName = z.getValue("Name") lMembers.append(mName) Then I later try to write these values. Currently I'm just displaying them for debugging. for i in lMembers: wMembers = lMembers arcpy.AddMessage(lMembers) arcpy.AddMessage(wMembers) Not quite sure what I'm doing incorrectly thanks in advance for you help Jon
... View more
07-31-2012
08:34 AM
|
0
|
21
|
6928
|
|
POST
|
I'd also like to add my 2 cents. Support for downloading GPS units to ArcMap is sorely missing at this time, simple products can seemingly easily download and upload tracks and points to and from GPS units. The core comms agent must be there somewhere as you can connect a real time GPS now to ArcMap, but not download tracks or waypoints. This is core functionality that is missing from such a robust product such as ArcMap. Heck even the FREE Explorer can import GPX files natively while the expensive and robust ArcMAP simply can't. I feel that ALL public safety departments and teams would give ESRI a huge round of applause if they would add support to pull data directly from GPS units. A bigger round if we had the ability to push polygons and points to the GPS also. Thanks
... View more
04-26-2011
04:06 PM
|
0
|
0
|
4407
|
|
POST
|
Is it still the case that there isn't a way to turn DDP on/off within Python?
... View more
04-05-2011
10:11 AM
|
0
|
0
|
1726
|
|
POST
|
I'm also hopelessly lost on your explanation here. Sorry "You also need to assign a handler to the queryTask. You can do this in the MXML by declaring a function in the result property, actionscript by adding an eventlistener, or by binding the executedLastResult of the query task to a component."
... View more
03-23-2011
01:02 PM
|
0
|
0
|
2099
|
|
POST
|
Thanks again John. I had just found out about declaring the var outside the function so i did move it. i see the changes in the function code and 'get' those, not quite sure what you mean about queryAssignment.where=resultPeriod if I change the query to exactly this I get an error that quotes are expected, if I add quotes I get an error that 'State' where was referenced without being declared. Again thanks for helping
... View more
03-23-2011
12:21 PM
|
0
|
0
|
2099
|
|
POST
|
Thanks very much John, you can probably tell I'm a newbie and had no idea you didn't need {} within actionscript. I'm pretty close I think but the query itself isn't executing. here's what I have. Here�??s the defined query
<esri:QueryTask
id="queryTaskAssignments"
url="http://blah blah/MapServer/6"
/>
<esri:Query
id="queryAssignments"
returnGeometry="true"
outFields="[assignment_number,team_name,timeslider,team_name,description]"
where="resultPeriod"
/>
Here�??s the button and text box
<s:TextInput id="textPeriod" enabled="true"/>
<s:Button id="textButton" label="Go" enabled="true" click="textButton_clickHandler(event)"/>
Here�??s the actionscript
// function to return assignments to data grid
public function textButton_clickHandler(event:MouseEvent):void
{
var resultPeriod:String = "";
if (textPeriod.text>"") {
resultPeriod = new String('period ='.concat(textPeriod.text))
}
if (textPeriod.text=="") {
resultPeriod = "1=1"
}
queryTaskAssignments.execute(queryAssignments);
}
I tested with Alert.Show(resultperiod) and get the correct strings to pass to the where= statement, no compiler errors but it�??s not firing the query. Is there something I need to do to pass values from with an actionscrip to mxml? Thanks again Jon
... View more
03-23-2011
10:56 AM
|
0
|
0
|
2099
|
| Title | Kudos | Posted |
|---|---|---|
| 3 | 07-11-2013 02:09 PM | |
| 2 | 07-31-2012 09:51 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|