question

Xu Z avatar image
0 Likes"
Xu Z asked Jeff Nordgren edited

how to use commands like setpickingdrawfocus and drawobjectpart?

i found commands like setpickingdrawfocus and drawobjectpart in the ASRSvehicle and Crane's draw and click code in the library, and i learn these commands maybe are the good choice to interact with the 3d view modles to resize them or do something else from this posts . and i tried to use these command to have a function test , but i didn't find any results. and i think maybe i use them in a wrong way, so could anyone give me an application case about this issue. any advise or excamples will be appreciated!

,

FlexSim 16.2.2
setpickingdrawfocus
· 4
5 |100000

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

Sam Stubbs avatar image Sam Stubbs ♦ commented ·

You can always look up the the commands in the Command helper, and view the more detailed documentation of each command. (Either push F1 when the cursor is clicked on a command, or lookup that command in the Helper. Help > Command Helper.) Here is the info about setpickingdrawfocus. (Unfortunately I've never used it, so maybe someone here will have a better application example than me. There is a small bit of example code at the bottom of the documentation.)

Parameters

(obj theview, obj focus, num what[, obj secondaryfocus, num flags])

Description

For developer use. Sets the draw code following this call to be picked as the focus when clicking or dragging. Usually you would use this to draw custom sizers and grippers on your object, and then implement an OnDrag or an OnClick event on the object that would call getpickingdrawfocus() to figure out what part was clicked.
flags is a bitwise combination of one "DETECT_DRAG" setting, as well as optional "override" bits. The override bits aren't used to define picking focus, but will cause FlexSim to override its normal drawing of sizers and bounding boxes.
DETECT_DRAG_X, DETECT_DRAG_Y, DETECT_DRAG_Z - will only detect dragging along the given axis, relative to the object being drawn. Use this with the draginfo() command in your OnDrag event to determine where the object is being dragged.
DETECT_DRAG_XY, DETECT_DRAG_YZ, DETECT_DRAG_XZ - will only detect dragging along the given plane. Again you would use this with the draginfo() command in the OnDrag event.OVERRIDE_DRAW_SIZER_X, OVERRIDE_DRAW_SIZER_Y, OVERRIDE_DRAW_SIZER_Z, OVERRIDE_DRAW_SIZER_X_NEG, OVERRIDE_DRAW_SIZER_Y_NEG, OVERRIDE_DRAW_SIZER_Z_NEG, OVERRIDE_DRAW_SIZER_ALL - these flags will cause the engine to not draw the flagged sizers
OVERRIDE_DRAW_YELLOW_BOX - causes FlexSim to not draw the yellow box around the object when selected
OVERRIDE_DRAW_GREEN_BOX - causes FlexSim to not draw the green "statistics-active" box around the object
OVERRIDE_DRAW_REDBOX - causes FlexSim to not draw the red selection box around the object when selected
OVERRIDE_DRAW_HOVERBOX - causes FlexSim to not draw the yellow hover box around the object when hovering over it
OVERRIDE_DRAW_ALL - causes FlexSim to not draw any sizers or boxes around the object

Example

setpickingdrawfocus(view, current, 20, drawsurrogate(current).first.subnodes[3], DETECT_DRAG_Y);

0 Likes 0 ·
Xu Z avatar image Xu Z Sam Stubbs ♦ commented ·

Hi sam,thanks for your reply. i have read the command description and that example, and i have made a model to run this command, i found nothing changed in the 3d model view.

0 Likes 0 ·
Sam Stubbs avatar image Sam Stubbs ♦ Xu Z commented ·

Hmm I'm not sure those commands are quite what you're looking for, I don't think those commands are used to specifically affect the drawing the 3D object, but redefining how it's going to be drawn based on what follows. This is more complicated coding usually used by the developers

I think perhaps we'll want to find a work around instead. What is it specifically you're trying to do?

1 Like 1 ·
Xu Z avatar image Xu Z commented ·

Hi Sam, what i want to do is very simple, i developed my own type ASRSvehicle model, and i want to give it a function like when i click the modle in 3d view, it would be shown like following picture:ondrawobjectpart-issue.png. and what you should pay attention is the special part, and it is what i'm trying to do. with this function i can let the user to redefine the size of rail length inside the obejct by just draging the specai part.


0 Likes 0 ·

1 Answer

Sam Stubbs avatar image
1 Like"
Sam Stubbs answered Jeff Nordgren edited

So it sounds like if you're just trying to set the length of the rail, all you need to do is access the spatialsx of the toprail and bottomrail of the ASRS vehicle. The toprail and the bottomrail are objects within the ASRS vehicle, and to change their length, you just need to set the spatialsx variable.

Here is an example model created by one of our support members that gives a simple code example of how you can set these properties.

asrs-railchangecode-2016u2.fsm


· 1
5 |100000

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

Xu Z avatar image Xu Z commented ·

@Sam Stubbs

Hi sam thank you so much, it is what i want to do but not excatly by the way I expected. i want to let user interact with the 3d model by just draging the specail part to resize the rail object inside, not directly by the commands. Maybe you can just give me an example about how to use the command setpickingdrawfocus and drawobjectpart.

0 Likes 0 ·