Model Background drawcube issue

Model Background drawcube issue

wproctorPG49C
Enthusiast Enthusiast
354 Views
2 Replies
Message 1 of 3

Model Background drawcube issue

wproctorPG49C
Enthusiast
Enthusiast

I am using a drawcube command in my Model Background On Draw trigger to draw phantom pallets at an AGV control point node.  This process seems to work fine but as the Y coordinate of the background increases, I am getting drift between the actual draw point and the model Y coordinate.  Is this a known issue and how do I fix this?

0 Likes
Accepted solutions (1)
355 Views
2 Replies
Replies (2)
Message 2 of 3

FelixMoehlmann
Collaborator
Collaborator

The location of things drawn in the OnDraw trigger are relative to the local coordinate system of the object the trigger is defined on. You need to use the ".project()" method of the Vec3 class to transform the coordinates of the control point.

Object cp = ...;
Vec3 cpLocation = cp.getLocation(0.5, 0.5, 0).project(cp.up, current);
drawcube(cpLocation.x, cpLocation.y, cpLocation.z, ...);

The size of the drawn shapes is also scaled based on the size of the trigger object. To not have this happen use "drawtomodelscale(current)" once before drawing anything in the trigger.

0 Likes
Message 3 of 3

wproctorPG49C
Enthusiast
Enthusiast
Accepted solution

Thanks for the feedback.  I didn't try that method, but I was able to get help from Brandon at FlexSim.  The issue ended up being that the background was drawn to scale and I was not applying the scale to the OnDraw commands (just trying to compensate in my position formulas).  Once I made the change, the cubes were aligned properly.

0 Likes