AlHanson Posted April 25, 2021 Share Posted April 25, 2021 Of all the complicated things I spent the morning working through, I can't believe that this is the one that is tripping me up- I'm struggling with properly rotating a lighting device in 3D just to force a fixture into an upright yoked position (180 on y Rotation, or 180x/180z as the OIP will recalculate to). My first attempt at this is using vs.LDevice_SetParamReal however this is doing absolutely nothing and doesn't provide any feedback so it's difficult to understand why. The used values should all be fine based off a previous investigation into this command a few months back. I also tried using the OIP name 'X Rotation' which also does not work (didn't expect it to). I also ran a loop and tried changing the cell and accessory index parameters around just to see if anything work take, but nothing did. vs.LDevice_SetParamReal(hObj, -1, -2, 'xRot', 180) vs.LDevice_GetParamReal(hObj, -1, -2, 'xRot') The Get version of this command works perfectly using the same values and properly retrieves whatever values I manually set the device to. Also, the Get command will retrieve the new values set via the Set command when run after the Set commands in the script, but the end result will still be no change. Running just the get again following this will show to the initial/current values not the values that were supposedly set in the previous script run. I assumed that maybe a reset command must be triggered to update the light but I've thrown LDevice_Reset, LDevice_ResetVisual, vs.ResetObject or the hell of it vs.ResetBBox into the mix but none help this. Eventually I gave up on the LDevice commands and went straight into the record commands which are giving me the exact same issues. I can read it, I can't set it. It shows as changed if I immediately Get following Set but does not actually update the device. vs.SetRField(hObj, 'Lighting Device', 'xRot', 90) x = vs.GetRField(hObj, 'Lighting Device', 'xRot') I went a step lower into vs.Set3DRot and vs.SetRot3D which *KINDA* work. It takes some math to get the points and such all set correctly and I can get the desired rotations but only if I switch views to 3D which gets a little clunky especially when I'm dealing with symbol rotation as well. Without script forcing the views into a 3D view these commands fail in top/plan view since it's a hybrid object. I'm sure I can kludge around this approach a bit more and make this all work, but it really seems like this shouldn't require any sort of work around for something so simple. Is the an approach I'm overlooking, some error in the values or just some bugs here? Anybody have a solution or insight? I feel like I'm missing something obvious here since this process should be a no brainer at this point... Quote Link to comment
JBenghiat Posted April 25, 2021 Share Posted April 25, 2021 SetEntityMatrix() should work. You’ll first need to get the matrix so you can pass the offset back to set. 1 Quote Link to comment
Sam Jones Posted April 25, 2021 Share Posted April 25, 2021 2 hours ago, JBenghiat said: SetEntityMatrix() ?? What matrix? Quote Link to comment
AlHanson Posted April 25, 2021 Author Share Posted April 25, 2021 SetEntityMatrix works like a charm @JBenghiat, even saved me a few lines of code. I'll have to use this one more often. Thanks! @Sam Jones Using SetEntityMatrix on the Lighting Device- the next value sets the X, Y, Z coordinates for the device, and the next three values represent the X, Y, Z rotation values. Example included. HTH # hObj = Handle of Lighting Device (BOOL, pioName, pioHandle, pioRecordHandle, pioWall) = vs.GetCustomObjectInfo() #Gets info from the current PIO zHeight = 48 ptLocation = vs.GetSymLoc(pioHandle) #2D Location of the Custom Plug-in Object xRot = 180 yRot = 0 zRot = 180 vs.SetEntityMatrix(hObj, ptLocation[0], ptLocation[1], zHeight, xRot, yRot, zRot) Quote Link to comment
JBenghiat Posted April 26, 2021 Share Posted April 26, 2021 @Sam Jones The position and rotation of an object can be expressed as its translation and rotation from the origin, which in turn can be expressed as a transformation matrix. https://www.tutorialspoint.com/computer_graphics/3d_transformation.htm Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.