question

Enrique Elizaga avatar image
1 Like"
Enrique Elizaga asked Phil BoBo edited

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

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.

FlexSim 17.2.2
object size
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Enrique Elizaga avatar image Enrique Elizaga commented ·

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 0 ·
Enrique Elizaga avatar image Enrique Elizaga commented ·

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 0 ·

1 Answer

·
Phil BoBo avatar image
3 Likes"
Phil BoBo answered Phil BoBo edited

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.


· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Enrique Elizaga avatar image Enrique Elizaga commented ·

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

0 Likes 0 ·
Enrique Elizaga avatar image Enrique Elizaga commented ·

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.

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Enrique Elizaga commented ·

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.

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.