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: 

Read data from URL with Revit API

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
SwainStrain
450 Views, 3 Replies

Read data from URL with Revit API

Hello everyone, 

 

I would like to create a plugin that reads data directly from a url. Currently I'm using Postman with the url to extract the data in an excel or json file:

IMG-20220128-WA0001.jpg

I wonder if it's possible to skip this passage and do it directly from Revit API.

I've never done anything like that and I'm asking your help to find some guide online with the passages to follow.

 

Thank you very much,

Letizia

Labels (3)
3 REPLIES 3
Message 2 of 4

Yes, this is definitely possible, although should not think of it in terms of the Revit API.   This will be a sidecare project that works alongside the Revit API.  I like Selenium for these tasks.  Get Selenium.WebDriver, NotNetSeleniumExtras.WaitHelpers, and Selenium.WebDriver.ChromeDriver (or whatever browser you prefer) from Nuget.  Then in your class call something like this:

 

IWebDriver driver = new ChromeDriver();
//Open webpage.  
driver.Navigate().GoToUrl("example");
		
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(600)); //wait 10 minutes if necessary

var element = wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible((By.CssSelector("tbody td:nth-child(2)"))));  //wait until whatever data you want is visible.

var bhpTRs = driver.FindElements(By.CssSelector("tr[data-fieldname='total brake horsepower']"));//get data

 

 

 

-Kevin Lawson, PE
www.rippleengineeringsoftware.com
Revit heating and cooling load calculations in one click!
Message 3 of 4
ricaun
in reply to: SwainStrain

To read data from url you could use System.Net.WebClient.

 

Something like this.

 

public string GetString(string address)
{
    using (var client = new System.Net.WebClient())
    {
        return client.DownloadString(address);
    }
}

 

See yaa

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

Message 4 of 4
SwainStrain
in reply to: SwainStrain

Thank you @Kevin.Lawson.PE  and @ricaun, still had no time to test it, I'll write my breakthrough here as soon as I have the chance. 

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

Post to forums  

Autodesk Design & Make Report