Amorphous Team Posted September 3 Share Posted September 3 Hi I’m totally new to Marionette. So I’d like to learn how to achieve the following as my first exercise. Often when we do our rendering, we’d like to ‘Open in 3D’ our doors, window, and cabinet objects. Currently you can only control them one by one which is difficult to handle when there are many objects So I’d like to create two different marionette scripts: (1) Open all ‘Window’, ‘Door’ and ‘Windoor’ objects at (a)‘Specific Angles for all’ or (b) ‘Different Random Angles for each’ in 3D (2) Open all ‘cabinet’ objects at (a)‘Specific Angles for all’ or (b) ‘Different Random Angles for each’ in 3D Any guidance would be appreciated Quote Link to comment
michaelk Posted September 4 Share Posted September 4 I'm not very good at Marionette, but I have 2 old Vector Scripts that do this with doors that may help you think about how it would work. (I use it to open all the doors before exporting to a web view). It's a very short script and may be easier (at least to me!) than writing a Marionette. Here's how I did it: 1. I only had it run on doors that had On Schedule checked. That way I wasn't trying to open cased openings. 2. To make it work you have to change the value of the "Show 3D open" checkbox to TRUE (or checked). BUT you will want to remember what it was so you can restore it. It's possible you want some doors to normally show open in 3D and some to not show open in 3D. 3. Some doors it makes sense to open 90 degrees, some 180, etc. Maybe you've had the foresight to use that value in the open angle of the door. Probably not, because it might look chaotic. 4. Whatever value you end up opening the door to, you want to restore it to what the open angle was to begin with. Enter the user fields. What the first script does is 1. Read the Show 3D open value (TRUE of FALSE). This will be written to User Field 10 2. Read the Open Angle of the door. Believe it or not, it's a string (text) of a number and not a number. This will be written to User Field 9 3. Check in on User Field 8. If there is a value in there, this will be used for the open angle. If not, the beginning open angle will be used. 4. Then set the value of Show 3d open to TRUE! Here's the first script: PROCEDURE OpenTheDoor; {14 April 2017} {Badly scripted by Michael Klaers} {This script preps the doors in a drawing to be ready to 'Export Web View' It preserves the 3D Open boolean and the open angle of each door in User Field 9 and 10 and then sets the 3DOpen to TRUE and the Open Angle to 90°} {There is a companion script that restores the doors to their original state} {ShouldILeaveThisOpen captures the value of door.3DOpen and stores it in user field 10. OrginalOpenAngle captues the value of Door.OpenAngle and stores it in user field 9. HowOpenisOpen is an alternate value for how far to open the door if the Door.OpenAngle is not the prefered value. HowOpenIsOpen is read from Userfield 8} VAR ShouldILeaveThisOpen : STRING; OriginalOpenAngle : STRING; HowOpenIsOpen : STRING; {------------------------------------------------------------Record & Open Procedure} PROCEDURE RecordAndOpen(h : HANDLE); BEGIN {Get Orig Door Settings} ShouldILeaveThisOpen := GetRField(h,'Door','3DOpen'); OriginalOpenAngle := GetRField(h,'Door','OpenAngle'); HowOpenIsOpen := GetRfield(h,'Door','UserFld8'); SetRField(h,'Door','UserFld9',OriginalOpenAngle); SetRField(h,'Door','UserFld10',ShouldILeaveThisOpen); IF GetRField(h,'Door','UserFld8') = '' THEN SetRField(h,'Door','OpenAngle',OriginalOpenAngle) ELSE SetRField(h,'Door','OpenAngle',HowOpenIsOpen); SetRField(h,'Door','3DOpen','TRUE'); ResetObject(h); END; {-----------------------------------------------------------------------Main Program} BEGIN ForEachObject(RecordAndOpen,(((R IN ['Door']) & ('Door'.'OnSched'=TRUE)))); END; RUN(OpenTheDoor); To restore the doors you just read the values from user fields 9 and 10 and write them back to the record. PROCEDURE CloseTheDangDoor; {14 April 2017} {Badly scripted by Michael Klaers} {This script restores the doors in a drawing after 'Export Web View' It recalls the 3D Open boolean and the open angle of each door from User Field 9 and 10 and then restores the 3DOpen Boolean and the Open Angle to their original values} {There is a companion script that records original state of the doors. Run that one first.} VAR OriginalOpenAngle : STRING; ShouldILeaveThisOpen : STRING; {------------------------------------------------------------Read & Restore Procedure} PROCEDURE WereYouBornInABarn(h : HANDLE); BEGIN OriginalOpenAngle := GetRField(h,'Door','UserFld9'); ShouldILeaveThisOpen := GetRField(h,'Door','UserFld10'); SetRField(h,'Door','OpenAngle',OriginalOpenAngle); SetRField(h,'Door','3DOpen',ShouldILeaveThisOpen); ResetObject(h); END; {----------------------------------------------------------------------Main Program} BEGIN ForEachObject(WereYouBornInABarn,(((R IN ['Door']) & ('Door'.'OnSched'=TRUE)))); END; RUN(CloseTheDangDoor); I'll attach a sample file with the scripts and a helpful worksheet. Note that Door 06 has Show 3D open checked. You can see that if you run the PRE script Door 01 opens 180 degrees because it has a value for User Field 8. Likewise, Door 02 only opens 10 degrees. And when you run the POST script door 6 doesn't close. It's value in User Field 10 is True. You can use the worksheet to change the values in User Field 8 and run the PRE script again to see the effects. Maybe someone will come along with an elegant Marionette and then we'll both know how to do it 🙂. Open and Close the Door.vwx 2 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.