Is there a way to maintain object size regardless of view zoom?

Is there a way to maintain object size regardless of view zoom?

enrique.elizaga
Advocate Advocate
678 Views
6 Replies
Message 1 of 7

Is there a way to maintain object size regardless of view zoom?

enrique.elizaga
Advocate
Advocate

[ FlexSim 17.2.2 ]

I want to keep an objects size fixed (always 2 x 2 x 2) independently of the zoom used in the view. Is this possible? Kind of what happens with the connections edges.

Accepted solutions (1)
679 Views
6 Replies
Replies (6)
Message 2 of 7

enrique.elizaga
Advocate
Advocate

An additional comment would be that I don't want the object to be screen-locked, and the it should keep its location in the model (x,y,z).

0 Likes
Message 3 of 7

enrique.elizaga
Advocate
Advocate

Hi @Jörg Vogel. Picture the same behaviour that the network nodes have. They have a fixed number of pixels regardless of the view zoom. And they are tied to a space location.

Is it possible to do with a plane or object?

0 Likes
Message 4 of 7

philboboADSK
Autodesk
Autodesk
Accepted solution

You can get this functionality using the Custom Draw Trigger by adding the following code:

double size = 5.0;
int shapeIndex = getshapeindex("fs3d\\Processor\\Processor.3ds");

double scaleFactor = size * viewpointradius(view).value / 100.0;
if (viewprojectiontype(view).value == 1) // orthographic projection
	scaleFactor = size * 10.0 / viewmagnification(view).value;
fglScale(scaleFactor, scaleFactor, scaleFactor);
drawobject(view, shapeIndex, 0);

That example code draws a Processor shape. You could adjust the getshapeindex() call to draw a different shape. For example, use "fs3d\\General\\Plane.3ds" to draw a plane.

You can adjust the size variable to make it draw bigger or smaller.

Attached is a sample model demonstrating this.

9026-object-size-ignore-zoom.gif



Phil BoBo
Sr. Manager, Software Development
Message 5 of 7

enrique.elizaga
Advocate
Advocate

@Jörg Vogel This is EXACTLY what I intended! You are a genious my friend!

0 Likes
Message 6 of 7

enrique.elizaga
Advocate
Advocate

Hi @Jörg Vogel is it possible to draw the 3d object (sphere) in the center of the node (like the red one). I tried with the midpoint selection but it won't work, it always generates it from one corner.

9227-3dobject-location.png

0 Likes
Message 7 of 7

philboboADSK
Autodesk
Autodesk

Add fglTranslate() calls to translate where the shape is drawn:

double size = 5.0;
int shapeIndex = getshapeindex("fs3d\\General\\Sphere.3ds");
double scaleFactor = size*viewpointradius(view).value/100.0;
if (viewprojectiontype(view).value == 1)
	scaleFactor = size*10.0/viewmagnification(view).value;
fglTranslate(0.5, 0.5, 0.5);
fglScale(scaleFactor, scaleFactor, scaleFactor);
fglTranslate(-0.5, -0.5, -0.5);
drawobject(view, shapeIndex, 0);

Or modify the shape in a 3D modeling program (such as AC3D) so that the shape is centered on the origin. The general sphere shape is positioned with its corner at the origin, not its center.



Phil BoBo
Sr. Manager, Software Development