Skip to content

Conversation

@Alex-Tsvetanov
Copy link
Collaborator

Example usage of the newly implemented class

	HostApp::Sketchup su;

	if (!su.active_model().has_value())
	{
		RubyUtils::Object("puts('No active model found.')");
		return;
	}
	RubyUtils::Object("puts('Active model found.')");

	HostApp::Sketchup::Model active_model = su.active_model().value();
	HostApp::Sketchup::View active_view = active_model.active_view();
	{
		HostApp::Geom::Point3d point = RubyUtils::details::IObject("Geom::Point3d.new(200, 100, 0)");
		active_view.draw_text(point, "This is a test");
	}
	{
		HostApp::Geom::Point3d point = RubyUtils::details::IObject("Geom::Point3d.new(200, 200, 0)");
		// You can setup options object via the constructor
		HostApp::Sketchup::View::DrawTextOptions options(
			std::pair{"font"sv, "Arial"}, 
			std::pair{"pixel_size"sv, 20}, 
			std::pair{"bold"sv, true}
		);
		// or by using .set member function
		options
			.set<"vertical_align">(HostApp::Sketchup::View::TextVerticalAlignBaseline)
			.set<"align">(HostApp::Sketchup::View::TextAlignRight);

		active_view.draw_text(point, "This is another\ntest", options);
	}
	{
		active_view.invalidate();
	}
	RubyUtils::Object("puts('Active view invalidated.')");

@Alex-Tsvetanov Alex-Tsvetanov requested a review from noelwarren May 28, 2025 16:43
@Alex-Tsvetanov Alex-Tsvetanov added the enhancement New feature or request label May 28, 2025
@noelwarren noelwarren merged commit f00602b into main Jun 2, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants