LDCad Scripting: cannot get group position/orientation


LDCad Scripting: cannot get group position/orientation
#1
Question 
Hello everybody,

I have built a LEGO model comprising of submodels, groups and some scripting functions.
The problem is my local script in LDCad cannot determine the position or orientation of a (toplevel) group.
Calling group:getPosOri() always returns the identity matrix (0 0 0 1 0 0 0 1 0 0 0 1).

these are the relevant lines:
Code:
local mainsf = ldc.subfile()
local mygroup = mainsf:getGroup('MyGroup')
local posori = mygroup:getPosOri()  --> identity matrix, whereas the editor window in LDCad shows clearly different values

If required I can also provide a small working example.

Can someone please explain what is going wrong here...  Huh

using LDCad 1.6 Beta 2a

Edit: model and script added


Attached Files
.mpd   GroupTest.mpd (Size: 608 bytes / Downloads: 1)
.txt   GroupTest.lua.txt (Size: 721 bytes / Downloads: 1)
Reply
RE: LDCad Scripting: cannot get group position/orientation
#2
Welcome to the forum Greg,

Things to check:
- Are you sure there is no relative grid active when checking the group posori in the editor as scripts always use absolute space.
- Is the matrix you expecting the one the groups main part uses, as groups always use the first part as its ori source, same goes for the position part unless the group uses a custom center.

I did a quick test and it seems to work fine for me using a rotated group, if you post or mail me your ldr/lua files I might be able to tell more.
Reply
RE: LDCad Scripting: cannot get group position/orientation
#3
I have attached 2 files to the OP (rename the script file to ".lua" first).
Since this is the most basic example, I feel something must be terribly wrong in my editor / model / script.

Yes, the (nested) editor uses absolute grid orientation (ABS), switching to REL shows the position of the currently selected group as (0, 0, 0).
Switching back to ABS shows the position of the first item of the group again.

Even though the bottom right in the editor always says '(rel) grid position  X; Y; Z'
Reply
RE: LDCad Scripting: cannot get group position/orientation
#4
(2017-03-20, 10:36)Greg Montgomery Wrote: I have attached 2 files to the OP (rename the script file to ".lua" first).
Since this is the most basic example, I feel something must be terribly wrong in my editor / model / script.

It is a bug, i just posted working results (removed it again) as it seemed to work for me at first glance.

But I just discovered that is because I used animation mode before testing this.

Thanks for reporting this very weird bug

edit: found the cause of this bug, it is best to not use group posOri io from macros until the next version. It is using the animation 'anti rounding error' stuff which you don't want in macros, forgot all about that Smile Sorry about that.
Reply
RE: LDCad Scripting: cannot get group position/orientation
#5
Alrighty then, thanks you for your help
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 1 Guest(s)