Navisworks General Discussion

Navisworks General Discussion

Reply
Valued Mentor
265 Posts
23 Kudos
Registered: ‎03-04-2004
Post 1 of 6

Scriptor & Scripts Examples or Samples.

818 Views, 5 Replies
06-23-2011 05:34 AM

Not being a 'programmer' per se, I am struggling with Scripts and Scriptor.  Can't seem to get my head around it as there are no real good explanations in the Help file.  Does anyone have or know of any decent examples wtih Scripting in it?

 

Mike

Michael L. Maloney
Virtual World Designs
VDC & BIM Model Design, Clash & Coordination
mike@VirtualWorldDesigns.com
Building Design Suite Ultimate 2013, 2014, 2015
Charlotte, NC ; Fort Mill, SC
Alumni
359 Posts
34 Kudos
Registered: ‎08-28-2009
Post 2 of 6

Re: Scriptor & Scripts Examples or Samples.

06-23-2011 11:07 AM in reply to: mike

Hi mike,


Here are some steps to create a script where the animation of a door opening plays when you are within a certain distance from the door:

First create the animation:

1. Open Animator from the Tools Panel of the Home tab.

2. Click the Add scene button to add a scene

3. In the scene view, select the door. When selecting the door, hold down shift to cycle through the selection resolution so that you only select the door and not the frame as well. Alternatively, select from the selection tree.

4. With the door selected, in the Animator tool, right click on the scene you created and select Add animation set > From Current Selection.

5. Click the rotate animation set button in Animator.  You should now see the rotate gizmo in the scene view.

6. In the scene view, select the X axis of the gizmo and drag the gizmo so that the origin is placed on the left side edge of the door.  This will allow the door to swing open rather than spin around.

7. Back in Animator, click the capture keyframe button. 

8. Drag the time slider or enter the time of 3 seconds to move the time slider to that point in time.

9. Drag the blue curve of the gizmo to rotate the door about the Z axis.

10. Click the capture keyframe button.  You’ll now have a keyframe at 3 seconds of the door open.

11. Unselect the rotate animation set so the gizmo is no longer displayed.  

12. Click the play button.  You should now have an animation of the door opening.


Now that you have the animation, create the script:

1. Open Scripter from the Tools Panel of the Home tab.

2. In the Scripter tool, click the add new script button.

3. In the events panel, click the on hotspot button.

4. In the properties of the On Hotspot event, set the radius to about 10 meters

5. For the Position click the Pick button, and the cursor will turn into a cross-hairs

6. Pick a point on the door in the scene view.

7. Back in Animator, in the actions panel, click the play animation button.

8. In the properties, set Animation to the animation set you previously created.

9. Very importantly, mark “Enabled Scripts” in the scripts panel of the Animation tab. Without this turned on, your scripts will not run.

You can now use the walk navigation tool to navigate closer to the door, and once you are within 10 meters, it should swing open.  If you want to play the animation again, just toggle scripts off/on.

Attached is the sample file I created from the steps above.  There is an animation you can play of the camera moving toward the door.  Make sure you have “Enabled Scripts” turned on when you play it.


Best regards,

autodesk_logo_signature.png

John Lipp
Product Support Specialist
Autodesk Product Support 

Valued Mentor
265 Posts
23 Kudos
Registered: ‎03-04-2004
Post 3 of 6

Re: Scriptor & Scripts Examples or Samples.

06-23-2011 11:27 AM in reply to: john.lipp

Thanks John,

 

I'll take a look at this and get back with you.  I'm sure there'll be more questions.  This is uncharted territory for me.

Mike

Michael L. Maloney
Virtual World Designs
VDC & BIM Model Design, Clash & Coordination
mike@VirtualWorldDesigns.com
Building Design Suite Ultimate 2013, 2014, 2015
Charlotte, NC ; Fort Mill, SC
Valued Contributor
55 Posts
3 Kudos
Registered: ‎10-07-2010
Post 4 of 6

Re: Scriptor & Scripts Examples or Samples.

10-12-2011 12:12 PM in reply to: john.lipp

After spending much time and trial with many errors, I found some neat thing with this feature.

 

  • In the hotspot editor, choose 'sphere on selection'. You need to select the item first and click on the set button to engage it.
  • I found that I could delete the animation in the viewpoints tab after the fact and it does not affect my door opening. This lets you hide all sorts of easter eggs in your model.
  • Speaking of easter eggs, I tried to do a hospot script where a bunny (sketchup file) would appear when I got close to a desk. It worked but closed my working file and opened the bunny file. Perhaps there is a way to do this...John?

Bunny

Employee
149 Posts
9 Kudos
Registered: ‎10-29-2009
Post 5 of 6

Re: Scriptor & Scripts Examples or Samples.

10-14-2011 06:13 AM in reply to: revitforbreakfast

Hi there,

 

I'm afraid I can see no simple way currently to allow your bunny to appear when you approach it. This would require either the Load Model script to allow append actions as well as replacement open actions, or alternatively, an action that allows you to hide or unhide the bunny on demand (and you append the bunny to the existing file in preparation).

 

You could conceivably animate or transform the bunny off into the distance at start of playback and snap it back at the point you desired (if I recall correctly, animations don't have to be smooth transitions but default to that). A little kludgy and it might cause odd model bounding box effects depending on where you moved it to, but it might be a suitable workaround depending on your scenario (e.g. animate/transform the bunny off inside a cupboard or something).

 

I'm not sure the act of deleting the viewpoint animation and still referring to it in Scripter is supposed to work quite like that. You may be relying on undefined behaviour there. Generally I'd recommend not deleting components of the file on which you are reliant :smileyhappy:

 

Hope that helps,

 

Jeff

 

PS: On the original question of how does one use Scripter, my concise take on it would be that Scripter is intended to be a way to link up events that trigger actions; each script representing one pairing of a set of events with a set of corresponding actions. It is a first take on providing interaction within your Navisworks model.

 

Each script is composed of one or more events that, when triggered via any desired logic (e.g. pressing a key OR moving into a hotspot), causes the associated actions to run. There is a variables system built in that enables more complex logic to built up out of multiple scripts e.g. you could have a script that OnKeyPress of J increments a variable, and another script that runs when that variable reaches three and plays an animation. With OnStart, OnAnimation, OnScript & OnTimer events, you can chain scripts & script effects together more directly.



Senior Software Engineer
Navisworks
Autodesk Ltd.
Active Member
7 Posts
0 Kudos
Registered: ‎04-04-2007
Post 6 of 6

Scriptor & Scripts Examples or Samples.

04-23-2012 05:47 PM in reply to: JeffH_ADSK
New to understanding and writting scripts or that this may be the right path. What I am trying to do is animate in timeliner a sequence during construction so that when the building is at the 6th floor and the horizontal safety nets display that the 4th floor safety next disappear. So as the building goes up the nets appear to be jumping in sequence. I assume that this type of script can cover things like a hoist or crane as well. Thank you for any support.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Have API Questions?
New Dedicated Forum for Navisworks API