Downloading a file from the Internet

On 20/01/2014 at 06:54, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R15 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------
I think I need to use HyperLinkCustomGui and HyperlinkData to download a file from the Internet.
Not to display it (that is done with HTMLViewerCustomGui), but to read and process it.

The manuals tells me "Hyper link data type ([CUSTOMDATATYPE_HYPER_LINK_STATIC](file:///D:/Users/pgrooff/Documents/pim/c4d/c++%20R15%20sdk/help/pages/customgui_hyperlink/enum_CUSTOM_HYPER_LI364.html#customdatatype_hyper_link_static1)) for use with the [HyperLinkCustomGui](file:///D:/Users/pgrooff/Documents/pim/c4d/c++%20R15%20sdk/help/pages/customgui_hyperlink/class_HyperLinkCusto821.html) GUI. Has to be created with [Alloc()](file:///D:/Users/pgrooff/Documents/pim/c4d/c++%20R15%20sdk/help/pages/lib_aes/class_AES9.html#alloc0) and destroyed with [Free()](file:///D:/Users/pgrooff/Documents/pim/c4d/c++%20R15%20sdk/help/pages/lib_aes/class_AES9.html#free1). You can use[AutoAlloc](file:///D:/Users/pgrooff/Documents/pim/c4d/c++%20R15%20sdk/help/pages/ge_autoptr/class_AutoAlloc33.html) to automate the allocation and destruction based on scope."

However, I do not know how to use them and I cannot find an example.

	BaseContainer hyperlinkc;
	hlcgsibl = (HyperLinkCustomGui* )AddCustomGui(1002, CUSTOMGUI_HYPER_LINK_STATIC, "Hyperlink", BFH_SCALEFIT|BFV_SCALEFIT, 900, 200, hyperlinkc);
  
	String linkTextsIBL = "http://www.hdrlabs.com/sibl/index.html";
	String labelTextsIBL = "Smart IBL overview";
	hlcgsibl->SetLinkString(&linkTextsIBL, &labelTextsIBL);

Pim

On 20/01/2014 at 08:01, xxxxxxxx wrote:

Hi Pim,

You just need to set HYPERLINK_IS_LINK to true in the HyperLinkCustomGui container.

On 21/01/2014 at 04:01, xxxxxxxx wrote:

Ok, then how do I tell cinema 4d where to store the downloaded data.
Do I need to Alloc the HyperlinkData and put that somewhere in the container?

On 21/01/2014 at 05:52, xxxxxxxx wrote:

Pim, do you want to download a file or display a link in a dialog where the user can download a file?

On 21/01/2014 at 11:53, xxxxxxxx wrote:

I want to download a file.
After downloading I will display the contents of the file using the treeview as we discussed in another post.

By the way, in Python it is very easy to do.
In our lon-lat plugin we connect to OSM, query the site and use the result (the contents) in our plugin.

On 23/01/2014 at 05:53, xxxxxxxx wrote:

Originally posted by xxxxxxxx

Hi Pim,
You just need to set HYPERLINK_IS_LINK to true in the HyperLinkCustomGui container.

Setting a link now works.

	//set labelText as link.
	BaseContainer hyperlinkc;
	hyperlinkc.SetBool(HYPERLINK_IS_LINK, true);
	hlcgsibl = (HyperLinkCustomGui* )AddCustomGui(1002, CUSTOMGUI_HYPER_LINK_STATIC, "Hyperlink", BFH_SCALEFIT|BFV_SCALEFIT, 900, 200, hyperlinkc);
  
	String linkTextsIBL = "http://www.link.com/index.html";
	String labelTextsIBL = "Link text";
	hlcgsibl->SetLinkString(&linkTextsIBL, &labelTextsIBL);

However still the question how to download data in a for C++ accessible form?
E.g. I want to download http://www.grooff.eu/countries.txt and put the input of this file in a treeview.

Use HyperlinkData, but how?

On 26/01/2014 at 06:52, xxxxxxxx wrote:

Still very unclear, how to download a file from the internet.
I can use HyperLinkCustomGui to define a link, but when clicked the file is openen in a browser and the file is not downloaded.
The manual tells to use HyperLinkData, but how?
In the example below, I do not use it.

	//set labelText as link.
	BaseContainer hyperlinkc;
	hyperlinkc.SetBool(HYPERLINK_IS_LINK, true);
	hlcgsibl = (HyperLinkCustomGui* )AddCustomGui(1002, CUSTOMGUI_HYPER_LINK_STATIC, "Hyperlink", BFH_SCALEFIT|BFV_SCALEFIT, 900, 200, hyperlinkc);
  
	String linkTextsIBL = "http://www.grooff.eu/pictures/download.txt";
	String labelTextsIBL = "Download test file.";
	hlcgsibl->SetLinkString(&linkTextsIBL, &labelTextsIBL);
  
	String pStrLink, pStrText;
	hlcgsibl->GetLinkString(&pStrLink, &pStrText);

On 28/01/2014 at 00:51, xxxxxxxx wrote:

Originally posted by xxxxxxxx

Still very unclear, how to download a file from the internet.
I can use HyperLinkCustomGui to define a link, but when clicked the file is openen in a browser and the file is not downloaded.
The manual tells to use HyperLinkData, but how?
In the example below, I do not use it.

HyperLinkData is only useful if a HYPERLINK parameter is defined in a description resource.
It allows to get/set the hyperlink text and link strings.

HyperLinkCustomGui only displays a link. If you need to download a file from an internet URL take a look at these pages on Stackoverflow:
http://stackoverflow.com/questions/1129194/download-a-url-in-c

http://stackoverflow.com/questions/1636333/download-file-using-libcurl-in-c-c

On 01/02/2014 at 02:56, xxxxxxxx wrote:

Thanks, I can now run curl using a command file and thus download a file.
I can get curllib to work in win32 mode, but not in x64 mode.
Getting it to work in x64 is a lot of work (too much).
Note: I use visual studio c++ 2010 express.

Yannick also showed me how to run python scripts, so I will proceed in that direction.
Python and Internet is straightforward.