Download

Online

Gallery

Blog

  Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 6
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 680 times and has 5 replies Next Thread
CyberShadow
Newbie




Joined: Apr 15, 2023
Post Count: 3
Status: Offline
Reply to this Post  Reply with Quote 
Move selection by an exact distance

Hi,

I made a mistake while trying to make an exact plan of an existing building.

In short, I need to move selected items by an exact distance (e.g. 1 meter north).

Is this possible?

I'm aware I can use the arrow keys or the mouse, however it is not possible to exactly control the distance. Arrow keys move items by some nonsense random amount like "1.0221" cm. (I guess it depends on the zoom level, but there's no way to set the zoom level so that 1 nudge = 1 cm OSLT either.)

Thanks!
[Apr 15, 2023, 9:34:30 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
hansmex
Advanced Member
Member's Avatar

Netherlands
Joined: Sep 26, 2009
Post Count: 3952
Status: Offline
Reply to this Post  Reply with Quote 
Re: Move selection by an exact distance

Use the plugin AdvancedEdit

H
----------------------------------------
Hans

new website - under constuction
hansdirkse.info
[Apr 16, 2023, 7:04:31 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
CyberShadow
Newbie




Joined: Apr 15, 2023
Post Count: 3
Status: Offline
Reply to this Post  Reply with Quote 
Re: Move selection by an exact distance

Thank you!

I also submitted the following patch, which I think makes sense regardless (though, as these things go, no idea if it arrived anywhere or not):

From ae3f3435dde25fee5f9213c9c0333d78c641a49c Mon Sep 17 00:00:00 2001
From: Vladimir Panteleev <git@cy.md>
Date: Sat, 15 Apr 2023 22:20:06 +0000
Subject: [PATCH] Made the arrow keys move the selection by distances aligned
to user units

Arrow keys move selected items by a distance which depends on the zoom
level (scale), however this can be a little arbitrary.

Since the user operates on a grid with length values based in a
real-world system of measurements, it's usually more useful to allow
operating in terms of those values. In practical terms, this means
that users are more likely to find useful to move an item by 1 cm, as
opposed to e.g. 1.025641025 cm.

Make the arrow keys do this, by using a function which calculates a
scale value such that a unit distance will be greater than a pixel but
aligned to the user's preferred system of measurements.
---
.../sweethome3d/swing/PlanComponent.java | 36 ++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/src/com/eteks/sweethome3d/swing/PlanComponent.java b/src/com/eteks/sweethome3d/swing/PlanComponent.java
index 7d91535..ed75adb 100644
--- a/src/com/eteks/sweethome3d/swing/PlanComponent.java
+++ b/src/com/eteks/sweethome3d/swing/PlanComponent.java
@@ -1595,7 +1595,7 @@ public class PlanComponent extends JComponent implements PlanView, Scrollable, P
}

public void actionPerformed(ActionEvent ev) {
- controller.moveSelection(this.dx / getScale(), this.dy / getScale());
+ controller.moveSelection(this.dx / getAlignedScale(), this.dy / getAlignedScale());
}
}
// Toggle magnetism action
@@ -5584,6 +5584,40 @@ public class PlanComponent extends JComponent implements PlanView, Scrollable, P
return this.scale;
}

+ private static final float[] metricScaleSteps = {
+ 0.01f, 0.025f, 0.05f,
+ 0.1f, 0.25f, 0.5f,
+ 1f, 2.5f, 5f,
+ 10f, 25f, 50f,
+ 100f, 250f, 500f,
+ 1000f, 2500f, 5000f,
+ 10000f, 25000f, 50000f
+ };
+
+ private static final float[] imperialScaleSteps = {
+ 2.54f / 12 / 12, 2.54f / 12 / 4, 2.54f / 12 / 2,
+ 2.54f / 12, 2.54f / 4, 2.54f / 2,
+ 2.54f, 2.54f * 3, 2.54f * 6,
+ 2.54f * 12, 2.54f * 12 * 3, 2.54f * 12 * 6,
+ 2.54f * 12 * 12, 2.54f * 12 * 12 * 3, 2.54f * 12 * 12 * 6,
+ 2.54f * 12 * 12 * 12, 2.54f * 12 * 12 * 12 * 3, 2.54f * 12 * 12 * 12 * 6,
+ 2.54f * 12 * 12 * 12 * 12
+ };
+
+ /**
+ * Returns a scale value close to getScale(), but aligned to the user's preferred measurement units.
+ */
+ public float getAlignedScale() {
+ LengthUnit lengthUnit = this.preferences.getLengthUnit();
+ float[] scaleSteps = lengthUnit.isMetric() ? metricScaleSteps : imperialScaleSteps;
+ float pixelLength = getPixelLength();
+ for (int i = 0; i < scaleSteps.length; i++) {
+ if (scaleSteps >= pixelLength)
+ return 1 / scaleSteps / this.resolutionScale;
+ }
+ return this.scale;
+ }
+
/**
* Sets the scale used to display the plan.
* If this component is displayed in a viewport the view position is updated
--
2.40.0


[Apr 16, 2023, 12:17:51 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Keet
Advanced Member
Member's Avatar

Netherlands
Joined: Apr 8, 2022
Post Count: 789
Status: Offline
Reply to this Post  Reply with Quote 
Re: Move selection by an exact distance

As hansmex stated, use the Advanced Edit plugin. With that you can move all selected objects with great precision. It moves the exact distance you enter independend of the zoom level. For me it's the most used function in Sweethome3D. Even with the deepest zoom level you can only move 0.1 cm with the arrow keys. For a house that's fine but when you create furniture in SH3D that is often not precise enough. Using the Advanced Edit plugin you can go as small as 0.001 if you wanted to. Just don't move it with an arrow key until you have exported the furniture.
Bonus: it can move ANY object, including polylines, dimensions, walls, rooms, etc. So you can drag a selection square and move everything in the selection in one go.
[Apr 16, 2023, 4:54:53 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
CyberShadow
Newbie




Joined: Apr 15, 2023
Post Count: 3
Status: Offline
Reply to this Post  Reply with Quote 
Re: Move selection by an exact distance

Thanks, got it 🙂
For a house that's fine but when you create furniture in SH3D that is often not precise enough.
I have not tried it, but would a 3D modeling program like Blender not be better for creating furniture?
Even with the deepest zoom level you can only move 0.1 cm with the arrow keys.
So the distance that the arrow keys move things by depends on the zoom level... is the 0.1 cm limit because you can only zoom in so far? It's hard-coded in the getMinimumScale() method. Um... if it helps you, I could make you a build with that limit removed.
[Apr 16, 2023, 11:18:29 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Keet
Advanced Member
Member's Avatar

Netherlands
Joined: Apr 8, 2022
Post Count: 789
Status: Offline
Reply to this Post  Reply with Quote 
Re: Move selection by an exact distance

I have not tried it, but would a 3D modeling program like Blender not be better for creating furniture?
Any 3D modelling program that can export to one of the formats supported for import in SH3D is fine. However there's a huge difference in learning curve between the different programs. Blender has long and very steep learning curve where assembling basic shapes in SH3D is simplicity itself. It's what you know or are willing to learn.
So the distance that the arrow keys move things by depends on the zoom level... is the 0.1 cm limit because you can only zoom in so far? It's hard-coded in the getMinimumScale() method. Um... if it helps you, I could make you a build with that limit removed.
No need for a special build. The advanced edit plugin partly goes around that limit and I suspect that one of the future releases of SH3D will increase zoomlevels and hopefully precision. A good trick is to build furniture in scale 10:1 and after export divide by 10 when importing. The 0.1 limit suddenly is 0.01 using that trick. And if that is not enough there's other programs that can. I use Blender for a few tasks that can't be done in SH3D like bisecting or smooting. I've become quite proficient in editing obj and mtl files too laughing
[Apr 17, 2023, 2:49:57 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

    Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads
   
© Copyright 2006-2024 eTeks - All rights reserved