Creating a solution When a user changes an IFC web viewer, the Revit project is updated simultaneously

Creating a solution When a user changes an IFC web viewer, the Revit project is updated simultaneously

r_b_1366
Explorer Explorer
345 Views
3 Replies
Message 1 of 4

Creating a solution When a user changes an IFC web viewer, the Revit project is updated simultaneously

r_b_1366
Explorer
Explorer
Hi, is there a solution to update your revit project when users make a change in the ifc webviewer? I want to create a plugin that updates the ifc web viewer simultaneously in revit. This is a simple code but I don't think it is correct. Please help me

public class IFCUploader : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
// Get the current Revit application and document
UIApplication uiApp = commandData.Application;
Document doc = uiApp.ActiveUIDocument.Document;

// Select an IFC file to upload
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "IFC Files|*.ifc";

if (openFileDialog.ShowDialo

g() == DialogResult.OK)
{
string ifcFilePath = openFileDialog.FileName;

// Implement code to upload the file to your web application using HTTP requests
// Ensure you handle any necessary authentication and provide the correct endpoint URL

string endpointUrl = "yourwebapp.com/upload";
string response = UploadFileToWebApp(ifcFilePath, endpointUrl);

TaskDialog.Show("Success", "IFC file successfully uploaded to the web app!");
return Result.Succeeded;
}

TaskDialog.Show("Error", "No IFC file selected.");
return Result.Cancelled;
}

private string UploadFileToWebApp(string filePath, string url)
{
// Implement the logic to send the IFC file to your web application using HTTP requests
// You can use RestSharp, HttpClient, or any other library for sending the file

// Example using HttpClient:
HttpClient client = new HttpClient();
MultipartFormDataContent form = new MultipartFormDataContent();
form.Add(new StreamContent(File.OpenRead(filePath)), "file", Path.GetFileName(filePath));

HttpResponseMessage response = client.PostAsync(url, form).Result;
string responseBody = response.Content.ReadAsStringAsync().Result;

return responseBody;
}
}

 

 

0 Likes
346 Views
3 Replies
Replies (3)
Message 2 of 4

jeremy_tammik
Alumni
Alumni

Yes. Check out my series of discussions on connecting the desktop and the cloud:

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 4

r_b_1366
Explorer
Explorer

Hi Jeremy thank you for your reply and thank you for your open-source code. I have read your RoomEditorApp and FireRatingCloud you use MongoDB NoSQL database for exporting and importing data. But I want to create a plugin in Revit that exports and imports the IFC File as well as updates my model by IFC. because my viewer gets the IFC file. Is there any way to store the IFC file in NOSQL and send it to the IFC web viewer? maybe this photo can explain it better than me. I read two articles on this subject which I am attaching.Thank you 

 https://www.iaarc.org/publications/fulltext/ISARC2016-Paper108.pdf 

 https://sciendo.com/article/10.2478/pcr-2022-00021.PNG

0 Likes
Message 4 of 4

jeremy_tammik
Alumni
Alumni

My intention with the reply is simply to state that it is possible to round-trip data from Revit desktop to the cloud and back again in more or less real time. That was and is my understanding of your question. The rest is up to you. Good luck and have fun!

  

That said, you can store anything you like in almost any container you like, but I would not recommend doing so. An IFC file, for instance, can live perfectly well on its own without being stuffed into a database.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes