I've got some JS code (see below) that is bugging me (pun intended). I'm probably overlooking something stupid simple but... I'm trying to cycle throught the proposals and set each one at a time as the active proposal. I can't get the SetProposalName function to work. I'm looking at the SetProposalName function and I'm not 100% sure if that means set a new name for a proposal or set a proposal current based on a name. Can someone shed some light on this for me and point me in the right direction?
// Get the active document var doc = app.ActiveDocument(); // Get all proposals in the model, cycle through them & print them to the debug panel var varProps = doc.GetAllProposals(""); for (x in varProps) { print (varProps[x]); }
Thanks!
Matt Wunch
Revit Subject Matter Expert/sUAS Pilot
Twitter | LinkedIn
AU2017 - Code Blue Dr Revit - How to Resuscitate Corrupt Revit Models
Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.
Solved! Go to Solution.
Solved by elliott.rosenfeld. Go to Solution.
I think there's a piece missing here? From looking at your .js, it seems like you only end up printing the names of proposals to the debug window..For example, when you change a storyboard name, there's another step:
1 // Get the active document
2 var doc = app.ActiveDocument();
3
4 // Get current storyboard
5 var currentStoryboard = doc.Timeline.GetCurrentStoryboard();
6
7 // Change the name of a storyboard
8 currentStoryboard.Name = "My Storyboard with a new Name";
When I test out your code, the script executes, but there's still more to be done.
Here's what I see when I run your code (below). The script has executed the Get of ALL proposals.
But, if I do some tweaks, I can then print AllProposals. You can see that the console printed out the names of the 3 proposals in my model (master, proposal1, and Proposal2). Interestingly, it looks like Proposal2 is printed out first, which is coincedentally also the active proposal.
But if I change my JS a bit, I can instead print the name of the current, aka active proposal.
var doc = app.ActiveDocument(); var currentProposal = doc.GetActiveProposal(); print(currentProposal)
I know this doesn't completely answer your questions, but hopefully this helps! (Sorry, I'm not a JS expert, just guesstimating some of these things).
I think you may need to return doc.GetAllProposals as an array, and then somehow cycle through all Proposals, setting them active one at a time... if that is your intended result?
Thanks!
Elliott
Matt Wunch
Revit Subject Matter Expert/sUAS Pilot
Twitter | LinkedIn
AU2017 - Code Blue Dr Revit - How to Resuscitate Corrupt Revit Models
Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.
So I was messing around with my code and going through the JS documentation and I don't know how I missed them but there are ChangeProposal and ActiveProposal functions, both of which I can't figure out how to actually apply them. The follow code will run without any issues but nothing seems to happen. To give you a little background of my model I have two proposals: master and Test01. When I have Test01 active and run the code, the proposal doesn't change. I can't figure out how to commit the change and actually update the current proposal. Got any thoughts?
// Current proposal is 'Test01'
var doc = app.ActiveDocument(); doc.ChangeProposal = "master"; doc.ActiveProposal = "master";
Matt Wunch
Revit Subject Matter Expert/sUAS Pilot
Twitter | LinkedIn
AU2017 - Code Blue Dr Revit - How to Resuscitate Corrupt Revit Models
Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.
JS documentation says this about the ChangeProposal function.
But it's not switching.
Matt Wunch
Revit Subject Matter Expert/sUAS Pilot
Twitter | LinkedIn
AU2017 - Code Blue Dr Revit - How to Resuscitate Corrupt Revit Models
Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.
Took me a while to figure it out, but this seems to work:
var doc = app.ActiveDocument(); doc.ChangeProposal("master");
Thanks @elliott.rosenfeld!! I knew it had to be something stupid simple!
Matt Wunch
Revit Subject Matter Expert/sUAS Pilot
Twitter | LinkedIn
AU2017 - Code Blue Dr Revit - How to Resuscitate Corrupt Revit Models
Was this answer helpful? If so, please click the ACCEPT AS SOLUTION or the KUDO button.
No problem Matt, it was fun to mess around with some scripts. It does always come down to that, huh 🙂
Can't find what you're looking for? Ask the community or share your knowledge.