-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************

ScriptName = "SZ_HidePoints"

-- **************************************************
-- General information about this script
-- **************************************************

SZ_HidePoints = {}

function SZ_HidePoints:Name()
	return self:Localize("Name")
end

function SZ_HidePoints:Version()
	return "1.0"
end

function SZ_HidePoints:UILabel()
	return self:Localize("Name")
end

function SZ_HidePoints:Creator()
	return "Stan aka Vodka"
end

function SZ_HidePoints:Description()
	return self:Localize("Description")
end




-- **************************************************
-- Recurring values
-- **************************************************

-- SZ_HidePoints.value1 = false

-- **************************************************
-- Is Relevant / Is Enabled
-- **************************************************

function SZ_HidePoints:IsRelevant(moho)
	if moho:LayerAsVector(moho.layer) then
		return true
	end
	return false
end

function SZ_HidePoints:IsEnabled(moho)
	if moho:LayerAsVector(moho.layer) then
		return true
	end
	return false
end


-- **************************************************
-- The guts of this script
-- **************************************************

function SZ_HidePoints:Run(moho)

	moho.document:PrepUndo(moho.layer)
	moho.document:SetDirty()
	
	local mesh = moho:Mesh()
	local somePointsAreSelected = false
	
	for i=0, mesh:CountPoints()-1 do
		local point = mesh:Point(i)
		if point.fSelected then
			somePointsAreSelected = true
			break
		end
	end
		
	if somePointsAreSelected then
		for i=0, mesh:CountPoints()-1 do
			local point = mesh:Point(i)
			if not point.fSelected then
				point.fHidden = true
			else
				point.fSelected = false
			end
		end
	else
		for i=0, mesh:CountPoints()-1 do
			local point = mesh:Point(i)
			point.fHidden = false
		end
	end
	
end


function SZ_HidePoints:Localize(text)
	local fileWord = MOHO.Localize("/Menus/File/File=File")
	
	local phrase = {}
	
	phrase["Name"] = "Hide Points"
	phrase["Description"] = "Hides all points except selected, or unhides all points, if none is selected"
	
	
	if fileWord == "Файл" then
		phrase["Name"] = "Спрятать точки"
		phrase["Description"] = "Прячет все невыделенные точки. Если ничего не выделено, включает видимость всех точек"
	end
	
	return phrase[text];
end



Icon
Hide Points
Listed

Author: Stan View Script
Script type: Button/Menu

Uploaded: Dec 26 2020, 23:01

Click the button and all points except the selected ones will be hidden. Click it again and all points are revealed.
Image

Installation Options:

This script, and all other scripts on this site are distributed as free software under the GNU General Public License 3.0 or later.
Downloads count: 96