Jump to content
Sign in to follow this  
shezan74

Unable to see and remove an object

Recommended Posts

Hi all, i've a painful problem on my Island.

I've placed a taxiway piece as an object to try, due the fact the piece itself was not working as a road type.

Now i have 2 taxiways in the middle of my airport, visible on bulldozer (and with own proper ID) but invisible on Visitor3.

The objects are Exportable, so the program will "see" them but they're not selectable and i cannot remove them from terrain.

Removing the object from the whole map works, but the 2 pieces are still in place :(

Any ideas? Everything accepted...

Share this post


Link to post
Share on other sites

Sometimes closing and restarting visitor makes it visible in visitor. The other way may be the replace object menue....

Share this post


Link to post
Share on other sites

nothing... i've tried everything... i just managed to subst the object with another one (smaller) by patching the source file.

Now i'm trying to patch a V3 script (that correctly find, parse and export the objects on a text file) to DELETE them...

but i can't manage to find how to delete the selected item...

UPDATE: And I DID IT :)

---------- Post added at 10:44 PM ---------- Previous post was at 10:43 PM ----------

Well. i've created (modified) an original V3 script to perform the unselectable object deletion. This script can delete everything you need from the map, despite the fact it's selectable or not due a bug.

Feel free to use, as you keep original Bohemia Interactive copyright notice

// *************************************************************************************************************
// Copyright (C) 2007 Bohemia Interactive
// *************************************************************************************************************
// This script is free software for any non commercial use; you can redistribute it and/or modify as long as you
// include this licensing notice. This script is distributed in the hope that it will be useful, but without any
// warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
// *************************************************************************************************************
//
// DeleteObjects.vis
//
// *************************************************************************************************************
// This script allows to delete objects on the map, even in the case they are unselectable. 
// To do this, simply add the object to the artificial/natural object list and run the script.
// Warning: this script will DELETE every object of the selected type, not only the unselectable / bugged ones
// How to work: use the option "Objects from list" and select the unselectable objet you need to remove
// *************************************************************************************************************
// THE SCRIPT IS PROVIDED AS-IS AND WITHOUT ANY KIND OF WARRANTY
// SCRIPT ORIGINALLY PROVIDED BY BOHEMIA INTERACTIVE (EXPORT OBJECTS) AND REWORKED BY SHEZAN74
// FEEL FREE TO USE AND REWORK THIS FILE AS YOU LIKE, BY KEEPING ORIGINAL COPYRIGHT LICENSING NOTICE
// *************************************************************************************************************


// ---------------------
// functions definitions
// ---------------------

// **********************************************************************************************************
// IsAValidArea
// **********************************************************************************************************
IsAValidArea = 
{
private["_params", "_doc", "_area", "_vertices", "_test"];

// gets document and area 
_params = _this;
_doc  = _params select 0;
_area = _params select 1;

// gets the vertices under the area
_vertices = _doc getVerticesUnder _area;

// core - test validity
_test = true;
if(isnil("_vertices")) then
{
	_test = false;
};

// return value
_test
};


// **********************************************************************************************************
// GetNaturalTemplateNamesInDoc
// **********************************************************************************************************
GetNaturalTemplateNamesInDoc =
{
private["_doc", "_templates", "_templateNames"];

// gets the document
_doc = _this;

// gets 'natural' templates in the document
_templates = _doc getObjectTemplates "natural";
_templates sortBy {getName(_x) strCmp getName(_y)};

// core - gets template names
_templateNames = [];
{
	_templateNames = _templateNames + [getName _x];
} forEach _templates;

// return value
_templateNames
};


// **********************************************************************************************************
// GetArtificialTemplateNamesInDoc
// **********************************************************************************************************
GetArtificialTemplateNamesInDoc =
{
private["_doc", "_templates", "_templateNames"];

// gets the document
_doc = _this;

// gets 'artificial' templates in the document
_templates = (_doc getObjectTemplates "artificial");
_templates sortBy {getName(_x) strCmp getName(_y)};

// core - gets template names
_templateNames = [];
{
	_templateNames = _templateNames + [getName _x];
} forEach _templates;

// return value
_templateNames
};


// **********************************************************************************************************
// ErrorDialog
// **********************************************************************************************************
ErrorDialog =
{
private["_type", "_title", "_messageRow1", "_messageRow2", "_dlgError", "_result"];

// gets the type of warning
_type = _this;

// sets title and message
_title = "";
_messageRow1 = "";
_messageRow2 = "";
switch(_type) do
{
	case 1:
 		{
			_title = "Error in script execution";
			_messageRow1 = "Error in opening the specified file.";
 		};
	default
	 	{
			_title = "Warning - Error in dialog setting";
			_messageRow1 = "Error in ErrorDialog function.";
	 	};
}; 

// sets dialog
_dlgError = [220, 55, _title,
	      ["label", 200, 13, _messageRow1, 0], ["break"],
      	["label", 200, 13, _messageRow2, 0], ["break"],
   			["ok-button", 50, 13]];

// shows the dialog
_result = dialogBox _dlgError;

// return value
_result
};


// **********************************************************************************************************
// SetTemplatesList
// **********************************************************************************************************
SetTemplatesList =
{
private["_params", 
	  "_wantsNatural", "_wantsArtificial", 
	  "_naturalTemplsInDoc", "_artificialTemplsInDoc", 
	  "_templateNames"];

// gets the params
_params = _this;
_wantsNatural          = _params select 0;
_wantsArtificial       = _params select 1;
_naturalTemplsInDoc    = _params select 2;
_artificialTemplsInDoc = _params select 3;

// core - gets template names
_templateNames = [];

if (_wantsNatural) then
{
	_templateNames = _naturalTemplsInDoc;		 
};
if (_wantsArtificial) then
{
	_templateNames = _templateNames + _artificialTemplsInDoc;		 
};

// return value
_templateNames
};





// ---------------------------------
// internal variables default values
// ---------------------------------
_scriptName                    = "Delete Objects 1.0.0";
_areaObjects                   = [];
_selObjects                    = [];
_nAreaObjects                  = 0;
_nSelObjects                   = 0;
_nNaturalTemplateNamesInDoc    = 0;
_nArtificialTemplateNamesInDoc = 0;
_lblNAreaObjects               = "0 [No area selected]";
_lblNSelObjects                = "0 [No object selected]";
_showNaturalTemplateNames      = true;
_showArtificialTemplateNames   = true;
_naturalTemplateNamesInDoc     = [];
_artificialTemplateNamesInDoc  = [];
_selTemplates                  = 0;
_templatesList                 = [];
_saveAreaObjects               = false;
_saveSelObjects                = false;
_saveListObjects               = false;
_saveH                         = false;
_saveT                         = true;
_saveX                         = true;
_saveY                         = true;
_saveZrel                      = true;
_saveZass                      = false;
_saveO                         = true;
_dataSeparator                 = 0;
_fileName                      = "";
_lineCounter                   = 0;


echo "-----------------";
echo "ExportObjects.vis";
echo "-----------------";

// ------------------------
// gets the active document
// ------------------------
_doc = getActiveDoc;    

// ------------------------------
// gets the templates in document
// ------------------------------
_naturalTemplateNamesInDoc = _doc call GetNaturalTemplateNamesInDoc;
_artificialTemplateNamesInDoc = _doc call GetArtificialTemplateNamesInDoc;
_nNaturalTemplateNamesInDoc = count _naturalTemplateNamesInDoc;
_nArtificialTemplateNamesInDoc = count _artificialTemplateNamesInDoc;

// --------------------
// verify the templates 
// --------------------
_thereAreNaturalTemplateNames = false;
if(_nNaturalTemplateNamesInDoc > 0) then
{
_thereAreNaturalTemplateNames  = true;
};

_thereAreArtificialTemplateNames = false;
if(_nArtificialTemplateNamesInDoc > 0) then
{
_thereAreArtificialTemplateNames = true;
};

// ----------------------
// gets the selected area 
// ----------------------
_area = getSelectedArea _doc;

// ------------------------
// verify the selected area 
// ------------------------
_thereIsAnArea = false;
if (([_doc, _area] call IsAValidArea)) then    // there is an area selected in the document
{
_thereIsAnArea = true;
// ------------------------
// gets the objects in area
// ------------------------
_areaObjects = _doc getObjectsIn _area;
_nAreaObjects = count _AreaObjects;
_lblNAreaObjects = str _nAreaObjects;
};

// -------------------------
// gets the selected objects
// -------------------------
_selObjects = getSelectedPosEdObjects _doc;
_nSelObjects = count _selObjects;

// ---------------------------
// verify the selected objects 
// ---------------------------
_thereIsSelection = false;
if (_nSelObjects > 0) then    // there are objects selected in the document
{
_thereIsSelection = true;
_lblNSelObjects = str _nSelObjects;
};

// -----------------------
// sets the templates list
// -----------------------
_templatesList = [_showNaturalTemplateNames, _showArtificialTemplateNames, _naturalTemplateNamesInDoc, _artificialTemplateNamesInDoc] call SetTemplatesList;

// -------------------
// dialogs definitions
// -------------------
_dlgInput = [330, 380, _scriptName,
	["init",
		  {
			if(_thereAreNaturalTemplateNames) then
			{
				{
					_x dlgEnableControl true;
				} forEach dlgGetControls "_showNaturalTemplateNames";
			}
			else
			{
				{
					_x dlgEnableControl false;
				} forEach dlgGetControls "_showNaturalTemplateNames";
			};

			if(_thereAreArtificialTemplateNames) then
			{
				{
					_x dlgEnableControl true;
				} forEach dlgGetControls "_showArtificialTemplateNames";
			}
			else
			{
				{
					_x dlgEnableControl false;
				} forEach dlgGetControls "_showArtificialTemplateNames";
			};

			if(_thereIsAnArea) then
			{
				{
					_x dlgEnableControl true;
				} forEach dlgGetControls "_saveAreaObjects";
			}
			else
			{
				{
					_x dlgEnableControl false;
				} forEach dlgGetControls "_saveAreaObjects";
			};

			if(_thereIsSelection) then
			{
				{
					_x dlgEnableControl true;
				} forEach dlgGetControls "_saveSelObjects";
			}
			else
			{
				{
					_x dlgEnableControl false;
				} forEach dlgGetControls "_saveSelObjects";
			};

			if(_thereAreNaturalTemplateNames || _thereAreArtificialTemplateNames) then
			{
				{
					_x dlgEnableControl true;
				} forEach dlgGetControls "_saveListObjects";
			}
			else
			{
				{
					_x dlgEnableControl false;
				} forEach dlgGetControls "_saveListObjects";
			};

			if(!(_thereAreNaturalTemplateNames) && !(_thereAreArtificialTemplateNames) && !(_thereIsAnArea) && !(_thereIsSelection)) then
			{
				_id = 1;
				_id dlgEnableControl false;
			}
			else
			{
				if((count _fileName) == 0) then
				{
					_id = 1;
					_id dlgEnableControl false;
				}
				else
				{
					_id = 1;
					_id dlgEnableControl true;
				};
			};
		  }],
	["begin-subframe", 320, 190, " Selection "],
	    	["label", 130, 13, "Number of objects selected within area:", 0], 
	    	["dynlabel", 70, 13, "_lblNAreaObjects", 0], ["break"],
	    	["label", 130, 13, "Number of objects selected:", 0], 
	    	["dynlabel", 70, 13, "_lblNSelObjects", 0], ["break"],
		["begin-subframe", 310, 140, " Templates in document "],
			["extended-listbox", 200, 120, "_selTemplates", _templatesList], 
			["begin-subframe", 95, 120, ""],
			    	["check-box", 80, 13, "Natural objects", "_showNaturalTemplateNames"], 
				["onclick",
						{
							_templatesList = [_showNaturalTemplateNames, _showArtificialTemplateNames, _naturalTemplateNamesInDoc, _artificialTemplateNamesInDoc] call SetTemplatesList;
							"_selTemplates" dlgUpdateList _templatesList;	

							if(_showNaturalTemplateNames || _showArtificialTemplateNames) then
							{
								{
									_x dlgEnableControl true;
								} forEach dlgGetControls "_saveListObjects";
							}
							else
							{
								_saveListObjects = false;
								dlgUpdate "_saveListObjects";

								{
									_x dlgEnableControl false;
								} forEach dlgGetControls "_saveListObjects";
							};

							if(!(_showNaturalTemplateNames) && !(_showArtificialTemplateNames) && !(_thereIsAnArea) && !(_thereIsSelection)) then
							{
								_id = 1;
								_id dlgEnableControl false;
							}
							else
							{
								if((count _fileName) == 0) then
								{
									_id = 1;
									_id dlgEnableControl false;
								}
								else
								{
									if(_saveAreaObjects || _saveSelObjects || _saveListObjects) then
									{
										_id = 1;
										_id dlgEnableControl true;
									}
									else
									{
										_id = 1;
										_id dlgEnableControl false;
									};
								};
							};
						}], ["break"],
			    	["check-box", 80, 13, "Artificial objects", "_showArtificialTemplateNames"], 
				["onclick",
						{
							_templatesList = [_showNaturalTemplateNames, _showArtificialTemplateNames, _naturalTemplateNamesInDoc, _artificialTemplateNamesInDoc] call SetTemplatesList;
							"_selTemplates" dlgUpdateList _templatesList;

							if(_showNaturalTemplateNames || _showArtificialTemplateNames) then
							{
								{
									_x dlgEnableControl true;
								} forEach dlgGetControls "_saveListObjects";
							}
							else
							{
								_saveListObjects = false;
								dlgUpdate "_saveListObjects";

								{
									_x dlgEnableControl false;
								} forEach dlgGetControls "_saveListObjects";
							};

							if(!(_showNaturalTemplateNames) && !(_showArtificialTemplateNames) && !(_thereIsAnArea) && !(_thereIsSelection)) then
							{
								_id = 1;
								_id dlgEnableControl false;
							}
							else
							{
								if((count _fileName) == 0) then
								{
									_id = 1;
									_id dlgEnableControl false;
								}
								else
								{
									if(_saveAreaObjects || _saveSelObjects || _saveListObjects) then
									{
										_id = 1;
										_id dlgEnableControl true;
									}
									else
									{
										_id = 1;
										_id dlgEnableControl false;
									};
								};
							};
						}], ["break"],
			["end-subframe"], ["break"],
		["end-subframe"], ["break"],
	["end-subframe"], ["break"],
	["begin-subframe", 320, 60, " Objects to save "],
	    	["check-box", 80, 13, "Area objects", "_saveAreaObjects"], 
		["onclick",
				{
					if((count _fileName) == 0) then
					{
						_id = 1;
						_id dlgEnableControl false;
					}
					else
					{
						if(_saveAreaObjects || _saveSelObjects || _saveListObjects) then
						{
							_id = 1;
							_id dlgEnableControl true;
						}
						else
						{
							_id = 1;
							_id dlgEnableControl false;
						};
					};
				}], ["break"],
	    	["check-box", 80, 13, "Selected objects", "_saveSelObjects"], 
		["onclick",
				{
					if(!(_showNaturalTemplateNames) && !(_showArtificialTemplateNames) && !(_thereIsAnArea) && !(_thereIsSelection)) then
					{
						_id = 1;
						_id dlgEnableControl false;
					}
					else
					{
							if(_saveAreaObjects || _saveSelObjects || _saveListObjects) then
							{
								_id = 1;
								_id dlgEnableControl true;
							}
							else
							{
								_id = 1;
								_id dlgEnableControl false;
							};

					};
				}],["break"],
	    	["check-box", 80, 13, "Objects from list", "_saveListObjects"], 
		["onclick",
				{
					if(!(_showNaturalTemplateNames) && !(_showArtificialTemplateNames) && !(_thereIsAnArea) && !(_thereIsSelection)) then
					{
						_id = 1;
						_id dlgEnableControl false;
					}
					else
					{
							if(_saveAreaObjects || _saveSelObjects || _saveListObjects) then
							{
								_id = 1;
								_id dlgEnableControl true;
							}
							else
							{
								_id = 1;
								_id dlgEnableControl false;
							};

					};
				}],
				["break"],
	["end-subframe"], ["break"],

	["ok-button", 50, 13], ["cancel-button", 50, 13]];


_dlgOutput = [220, 100, _scriptName,
	 ["dynlabel", 200, 13, "_lineCounter", 2], ["break"],
	 ["label", 200, 13, "objects deleted", 2], ["break"],
		 ["ok-button", 50, 13]];


// -----------
// script core 
// -----------

// shows the input dialog
_result = dialogBox _dlgInput;

if(_result == 1) then
{
// ---------------------------
// sets the file to be written
// ---------------------------
	if(_saveAreaObjects) then     // objects under selection area
	{
		{
			delete _x;
			_linecounter = _linecounter + 1
		} forEach _areaObjects;
	};

	if(_saveSelObjects) then
	{
		{
			delete _x;
			_linecounter = _linecounter + 1
		} forEach _selObjects;
	};

	if(_saveListObjects) then
	{
		{
			_selName = _templatesList select _x;				
			_objsX = _doc getObjectsWithTemplate _selName;

			{
			delete _x;
			_linecounter = _linecounter + 1
			} forEach _objsX;

		} forEach _selTemplates;
	};

	// shows the output dialog
	_result = dialogBox _dlgOutput;

};

Edited by shezan74

Share this post


Link to post
Share on other sites

wow... not tested yet but if that really works would be great. We might need some more dedicated people with scripting knowledge to make visitor better...

Share this post


Link to post
Share on other sites

Use it carefully :) it solved my problem but can be further improved... the only trouble is to find informations on this language... i've tried by watching code and searching from other default scripts...

Anyway i'm improving it to remove only the selected objects from a selected area (can be useful to remove a single type of tree from a mixed forest in a specified area)

Share this post


Link to post
Share on other sites

it has frustrated me for a very long time that BIS hasn't given us any documentation about Visitor scripting... not even a basic list of Visitor commands for us to figure out by trial and error :\

I think somewhere on the biki there is one member's "sandbox" who somehow found a list of all the commands, actually... using some debug method or something like that... can't remember who or where it was though.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×