[Closed] update object position from 3rd party app
Greeting all
I have a dotnet.dll which listens to packets coming in over ethernet on a specific port. It includes a class (ThreeDSinterface) which contains methods to extract data from these packets I wish to apply to objects in my scene.
for example
$teappot.pos = (ThreeDSinterface.Data 1).position
moves the teapot to a new position based on stuff in the real world.
How would you go about moving the teapot around in realtime with the smallest impact on 3ds responsiveness/performace? Framerate isn’t a huge priority.
I used a dotnet timer as a proof of concept, but thought I’d get some opinions from smarter people before going much farther?
What about if you wanted to update the position of 200 objects? Would your answer change?
I’m fairly certain I won’t be able to run this in a background thread, as it, by necessity updates the viewport.
Cheers
Mikie
If in understand the situation correctly, I would create an event in your dotnet dll and register to it in maxscript.
If you add an EventHandler to your VS Project/DLL and load the .DLL into max as a Global variable like:
fn objPlacer_ChooseColor =
(
local placeColor = objectPlacer_Form.getPlaceColor()
local colorChosen = colorPickerDlg (color placeColor[1] placeColor[2] placeColor[3]) "Choose a Color - Object Placer" alpha:false pos:[200,200]
local a = FilterString (colorChosen as string) " "
if (colorChosen != undefined) do
(
objPlacer_bitmapPlacerCol = colorChosen
local strColor = a[2] + "," + a[3] + "," + subString a[4] 1 (a[4].count - 1)
objectPlacer_Form.setPlaceColor(strColor)
)
)
dotnet.loadassembly ((pathConfig.GetDir #MaxData)+"Scripts\ urboTools\ urboTools.ObjectPlacer.dll")
objectPlacer_Form = dotNetObject "turboTools.ObjectPlacer.form1"
dotNet.addEventHandler objectPlacer_Form "objPlacer_PickColor" objPlacer_ChooseColor
Then in your VS Project add an event Handler like
public event EventHandler objPlacer_PickColor; //Event to pick Color
in MXS, and send to C#
//Placement Color Clicked -- call the eventHandler on the Button
Click to Trigger Event in MXS
private void placementColor_Click(object sender, EventArgs e)
{
if (objPlacer_PickColor != null) objPlacer_PickColor(this, e);
}
That should work fine , and be fast enough to send from your DLL to MXS
Wow, that’s way better! Thanks! It also gives us a great way to optimize the number of events generated. (i.e. position must change in order to trigger an event)
Would you go with an event handler per object, or one that deals with all objects (1-200 objects)?
Neither. One event handler with a single object argument (or object handle argument).
@MikieK – I am very curious as to what you are doing here… I’ve played around with clumsy file read/writes with timers etc to get Grasshopperand Max “talking” But nothing truly integrated.
There are some cool examples of integration with UDK out there, where moving an object in Max, moves the corresponding object in UDK in real(ish) time.
Would/could you share what you’re working on?
I work for a specialist automation comapany. We use high end PLCs, and custom control hardware and software to fly/drive performers and scenery through venues for live entertainment/movies etc. My task was facilitate the importing of animation from 3ds max into our control system in a way which respects the high safety integrity level we must adhear to. In order to maintain safety, and reduce redundancy – objects, safety properties, allowed motion vectors, hierarchal relationships, are imported from the control system as starting blocks in 3ds, so the 3ds guy can focus on animating something pretty.
What I am working on now, is listening to ethernet ‘status’ packets for all the machines in a live control system, and feeding back that data into 3ds, to help speed up some animation workflow, and potentially porovide a visualization environment…
Incidentally, has anyone ever seen this error, or know what i means?
– Runtime error: dotNet runtime exception: Action being performed on this control is being called from the wrong thread. Marshal to the correct thread using Control.Invoke or Control.BeginInvoke to perform this action.
It was generate by a dotNetTreeview being updated as a consiquence of objects being moved around by external events …
.
Sorry, No help with your error message from me.
Your job description sounds fantastically interesting though. Would love to hear see/hear more.