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

How to solve multi-thread problem for loop set parameter.

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
cxyz278
926 Views, 3 Replies

How to solve multi-thread problem for loop set parameter.

Hi, everybody now i am facing a problem, i want to from  mysql read data and set this data to revit element parameter although I completed the mysql connection and set the parameters of the code,but i use timer1_Tick function to set parameters every second then revit crashes,i tried to use dynamo node to repeatedly read mysql data and use it to set element parameters,i think revit api can do the same thing.

You may ask me why not use dynamo, because when I use dynamo to do this, the program will be very slow so I want to try using revit  api to do this

Can anyone give me some advice or sample code?

Thank you all


mysql.JPG

3 REPLIES 3
Message 2 of 4
Revitalizer
in reply to: cxyz278

Hi,

 

bad idea.

 

One update per second is way to much.

You will prevent the user from editing data manually, this way.

https://forums.autodesk.com/t5/revit-api-forum/properties-dialog-doesnt-accept-input-when-commit-tra...

 

Also, you will pollute the undo stack, so the user will no be able to return to a given transaction within a couple of seconds.

 

Why not using the existing events, DocumentClosing, DocumentSaving, DocumentSavingAs etc.?

You still could trigger setting the parameters independent of any events - additionally, but not in a continuous loop...

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 3 of 4
cxyz278
in reply to: Revitalizer

Sorry, my English is not very good. I still don’t fully understand what you gave me.

Let me talk about what I want to do first,i want to use api  reach the effect of the following image,below image is i did it with  dynamo node ,the process is like third image , but dynamo is too slow .

So if I want to achieve this effect,is it possible for me to use some events as you said?

I want to build click start button then program start, continue until I press the Cancel button,is this a good idea? 

 

one patone pattwo pat as same timetwo pat as same time擷取.JPG

 

Message 4 of 4
Revitalizer
in reply to: cxyz278

Hi,

 

if you just want to display data in a model, you could use the AVF:

 

http://thebuildingcoder.typepad.com/blog/2017/03/rvtfader-avf-ray-tracing-and-signal-attenuation.htm...

 

You can create non-element geometry at runtime to get faces for displaying your values.

 

http://thebuildingcoder.typepad.com/blog/2011/12/using-avf-to-display-intersections-and-highlight-ro...

 

Note that you have more color and display options (color gradients, points, values, color legends) than you have using just

materials and plain colors.

 

What I meant by "undo stack" is this:

 

UndoStack.png

Every time you commit a transaction, there is a new entry in this list.

If you set parameters each second, there will be 60 entries after just a minute.

If the user is about to change another parameter and needs more than a second to do so, his changes will be rollbacked, as you can read in the forum topic I've linked.

 

I think the "Start" and "Cancel" buttons are a good way to show the user that he is in a sort of "playback mode", so he really knows that he cannot work on the model but can "enjoy the show".

 

 

Revitalizer

 




Rudolf Honke
Software Developer
Mensch und Maschine





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

Post to forums  

Rail Community


Autodesk Design & Make Report