I think I am missing something simple. How do I get the name of a selected feature or features in a tree? Thanks! Jeff
I am having trouble displaying multiple names at a time, but you can work on that with arrays. Also the code has to be specific on what type of objects they are. I assumed it was data. You'll have to mod the code for each object type (Reference, feature, etc) You also could code in a way to determine what type is selected. Here is some code:
Quote
version "4.0"
DECLARE datanames
DECLARE nb_data
DECLARE nb_data_select
DECLARE first_data 1
DECLARE iter 1
DECLARE onoff "Off"
#Find out how many data objects there are
TREEVIEW DATA GET_NB (nb_data)
#Find out how many data objects are selected
TREEVIEW DATA GET_NB_SELECTED (nb_data_select)
#Small loop to find out what is the first data object to be selected
while $onoff == "Off"
TREEVIEW DATA GET_SELECTION_STATUS ($first_data, onoff)
if $onoff == "Off"
++ first_data
endif
ENDWHILE
#Small loop to populate data names
while $iter <= $nb_data_select
TREEVIEW DATA GET_NAME ($first_data, datanames[$iter])
++ first_data
++ iter
ENDWHILE
#Confirmation of datanames in command history
ECHO ($datanames)
#attempt to diplay array of datanames, but it only displays the first one
MACRO PAUSE ("Names", "$datanames")
Thank you very much. This will at least get me started. I see it was not just a simple command. Thanks again! Jeff
The only way I can see everything in the array is to do them one at a time.
set iter 1
while $iter <= $nb_data
MACRO PAUSE ("Names", "$datanames[$iter]")
++ iter
endwhile
Is there a way to add to a string like you do with VB?
Dim test as string
test = test + datanames[$iter]
Would opening the names in a notepad file work?
Quoteversion "4.0"
DECLARE datanames
DECLARE dataname
DECLARE nb_data
DECLARE nb_data_select
DECLARE first_data 1
DECLARE iter 1
DECLARE onoff "Off"
#Find out how many data objects there are
TREEVIEW DATA GET_NB (nb_data)
#Find out how many data objects are selected
TREEVIEW DATA GET_NB_SELECTED (nb_data_select)
#Small loop to find out what is the first data object to be selected
while $onoff == "Off"
TREEVIEW DATA GET_SELECTION_STATUS ($first_data, onoff)
if $onoff == "Off"
++ first_data
endif
ENDWHILE
#Create text file to popluate the names to
DATA_FILE CREATE ("$_pwk_files_path\user-data\SelectedDataNames.txt", "ascii", "yes" )
#Small loop to populate data names
while $iter <= $nb_data_select
TREEVIEW DATA GET_NAME ($first_data, datanames[$iter])
TREEVIEW DATA GET_NAME ($first_data, dataname)
#Write name to the text file
DATA_FILE APPEND LINE ("$_pwk_files_path\user-data\SelectedDataNames.txt", "$dataname")
++ first_data
++ iter
ENDWHILE
#Confirmation of datanames in command history
ECHO ($datanames)
#Open Text File
SYSTEM ("Notepad.exe", "$_pwk_files_path\user-data\SelectedDataNames.txt")
I got the loop threw the array to do what I needed but I will have to use the text file later. Thanks for the help!
Hi there!
Thats the way I do it in "Version 5.0"
DECLARE aSelectedList
DECLARE iIndex 1
DECLARE iSelectedIndex 1
DECLARE iFeaturesNumber
DECLARE sFeatureStatus
TREEVIEW FEATURE COUNT GET ( iFeaturesNumber )
WHILE $iIndex < $iFeaturesNumber
TREEVIEW FEATURE SELECT GET ( $iIndex, sFeatureStatus )
IF $sFeatureStatus == "On"
TREEVIEW FEATURE NAME GET ( $iIndex, aSelectedList[$iSelectedIndex] )
++iSelectedIndex
ENDIF
++iIndex
ENDWHILE