Community
InfraWorks Forum
Welcome to Autodesk’s InfraWorks Forums. Share your knowledge, ask questions, and explore popular InfraWorks topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Javascript - SetProposalName function

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Matt__W
863 Views, 7 Replies

Javascript - SetProposalName function

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.

Tags (1)
7 REPLIES 7
Message 2 of 8
elliott.rosenfeld
in reply to: Matt__W

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:

 

// Get the active document

var doc = app.ActiveDocument();

3

// Get current storyboard

var currentStoryboard = doc.Timeline.GetCurrentStoryboard();

6

7 // Change the name of a storyboard

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.

JS.jpg

 

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.

moreJS.jpg

 

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)activeJS.jpg

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

 


Principal Specialist, Infrastructure
Message 3 of 8
Matt__W
in reply to: Matt__W

I know my code isn't complete. I couldn't figure out how to get it to do what I wanted. I used the print function as a check to make sure I was on the right track with iterating through the proposals collection.

I'll take a look at what you did later. Maybe I can hack something to work.

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.

Message 4 of 8
Matt__W
in reply to: Matt__W

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.

Message 5 of 8
Matt__W
in reply to: Matt__W

JS documentation says this about the ChangeProposal function.

 

IW_ChangeProposal.PNG

 

But it's not switching. Smiley Sad



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.

Message 6 of 8
elliott.rosenfeld
in reply to: Matt__W

Took me a while to figure it out, but this seems to work:

 

var doc = app.ActiveDocument();
doc.ChangeProposal("master");

Principal Specialist, Infrastructure
Message 7 of 8
Matt__W
in reply to: elliott.rosenfeld

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.

Message 8 of 8
elliott.rosenfeld
in reply to: Matt__W

No problem Matt, it was fun to mess around with some scripts. It does always come down to that, huh 🙂


Principal Specialist, Infrastructure

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report