DWF

Reply
Contributor
insiaiftiqhar
Posts: 19
Registered: ‎06-21-2012
Message 1 of 7 (1,151 Views)

reading 2D information from a dwf file

1151 Views, 6 Replies
06-25-2012 09:36 AM

I am trying to modify the "simpleW3DStreamReader" sample program to read 2D information.I made a vc10 build on win 7.

The DWFToolkit namespace in the VC10 build does not have the DWFEplot section , it has other classes though.When I compiled the DWFtoolkit lib for vc10 I did have some LNK4221 errors though which I suspect might be the cause. I couldn't get rid of them , I am supposed to replace all the deprecated funtion calls and recompile but I haven't had time to try it out. Do I need to manually add the object to the lib file? on the other hand ,the DWFPackageReader.getPackageInfo () call fails with a DWFIOException.It finds the .dwf file just fine(It is in the same folder as the executable but it returns null at line  _fp = ::_wfopen( rFilename, _zFlags ); in \dwfcore\win32\StreamFileDescriptor.cpp .Any thoughts and ideas are appreciated .Thanks in advance.

Contributor
binhpt
Posts: 14
Registered: ‎01-17-2012
Message 2 of 7 (1,141 Views)

Re: reading 2D information from a dwf file

06-26-2012 12:21 AM in reply to: insiaiftiqhar

You can view topic http://forums.autodesk.com/t5/DWF/Read-w2d-data-inside-DWF-file/td-p/1434298

please download dwfreader.cpp . 

 

^^

Contributor
binhpt
Posts: 14
Registered: ‎01-17-2012
Message 3 of 7 (1,140 Views)

Re: reading 2D information from a dwf file

06-26-2012 12:22 AM in reply to: binhpt
//
//  Copyright (c) 2007 by Autodesk, Inc.
//

// DWFReader.cpp : main project file.

// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined in
// section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized employees
// of Autodesk, Inc. is granted only under a written non-disclosure
// agreement, expressly prescribing the scope and manner of such use.


#include "StdAfx.h"

using namespace DWFCore;
using namespace DWFToolkit;

DWFCore::DWFInputStream *_global_input;
OpcHelper _global_helper;

WT_Result DWFInputStreamOpen(WT_File &file)
{
	file.set_stream_user_data(_global_input);
	return _global_input ? WT_Result::Success : WT_Result::File_Open_Error;
}

WT_Result DWFInputStreamClose(WT_File &file) 
{
	return WT_Result::Success;
}

WT_Result DWFInputStreamRead(WT_File &file, int desired_bytes, int &bytes_read, void *buffer)
{
	WT_Result res = WT_Result::Unknown_File_Read_Error;
	if(_global_input)
	{
		bytes_read = (int)_global_input->read (buffer, desired_bytes);
		res = WT_Result::Success;
	}

	return res;
}

WT_Result DWFInputStreamSeek(WT_File &file, int desired_bytes, int &bytes_seeked)
{
	WT_Result res = WT_Result::Unknown_File_Read_Error;
	if (_global_input)
	{
		_global_input->seek(SEEK_SET, desired_bytes);
		bytes_seeked = desired_bytes;
		res = WT_Result::Success;
	}

	return res;
}


DWFCore::DWFString ToDWFString(String^ input)
{
	wchar_t* dwfString_wt = static_cast<wchar_t*>(Marshal::StringToHGlobalUni(input).ToPointer());
	DWFString dwfString(dwfString_wt);

	return dwfString;
}

int main(array<System::String ^> ^args)
{
	WT_File inputStream;
	WT_Result result;
	DWFFile dwfFile(ToDWFString("c:\\test.dwf")); // any dwf file
	DWFPackageReader reader(dwfFile);
	DWFManifest& manifest = reader.getManifest();
	DWFManifest::SectionIterator* sections;

	sections = manifest.getSections();
	for(; sections && sections->valid(); sections->next())
	{
		DWFSection* dwf_section = sections->get();
		DWFToolkit::DWFResourceContainer::ResourceIterator *resources = dwf_section->findResourcesByMIME(ToDWFString("application/x-w2d"));

		if(!resources->valid())
			throw gcnew Exception("An error occurred accessing the resources in this section.");

		_global_input = resources->get()->getInputStream();
		inputStream.set_stream_close_action(&DWFInputStreamClose);
		inputStream.set_stream_end_seek_action(&DWFInputStreamEndSeek);
		inputStream.set_stream_open_action(&DWFInputStreamOpen);
		inputStream.set_stream_read_action(&DWFInputStreamRead);
		inputStream.set_stream_seek_action(&DWFInputStreamSeek);

		inputStream.set_file_mode(WT_File::File_Read);
		inputStream.open();
		xaml_file->desired_rendition() = inputStream.desired_rendition();

		while(inputStream.process_next_object() == WT_Result::Success)
		{
			const WT_Object* obj = inputStream.current_object();
			obj;
			// we can serialize the obj to another file
		}
	}

	inputStream.close();

	return 0;
}

 

Contributor
insiaiftiqhar
Posts: 19
Registered: ‎06-21-2012
Message 4 of 7 (1,130 Views)

Re: reading 2D information from a dwf file

06-26-2012 10:25 AM in reply to: binhpt

Thank you for your response. I had found that post previously and tried it with no luck. I tried it again today.Basically I get a plethora of linker errors ( lnk2019) when I try to setup an example project ( general empty vc ++ 2010 project) where I point to the  relevent lib files . I have rebuillt the dwf toolkit from source .I don't get such errors when I build off an existing sample. I have  done a Symbol dump on these lib files and have confirmed that these unresolved symbols are not missing . I am not sure what configuration is causing this...even If I built off of an example any call that opens the dwf file fails..I have tried working with many different dwf files to be sure it is not corrupted as well

for now a project tthat is setup properly so that I dont get a IO exception would be great..

 

int main(int argc, char* argv[])
{

     DWFFile dwfFile(  argv[1] );
     DWFToolkit::smileyvery-happy:WFPackageReader oReader( oDWF );
     DWFToolkit::smileyvery-happy:WFManifest& rManifest = oReader.getManifest();

// get sections from manifest

// cast sections to dwfEplotsection

// read attributes of the eplot section

...

       return 0;
}

Thanks again for your help, any pointers are appreciated..

Contributor
binhpt
Posts: 14
Registered: ‎01-17-2012
Message 5 of 7 (1,124 Views)

Re: reading 2D information from a dwf file

06-26-2012 06:00 PM in reply to: insiaiftiqhar

hi 

i will find for you some projects about reading 2d dwf. 

And if you want to build new project , please config project to linker to .lib in DWFToolkit-7.7\develop\global\lib , and include folder DWFToolkit-7.7\develop\global\src after that copy all file .dll you want in DWFToolkit-7.7\develop\global\bin to folder contains exe file (runtime require)

Contributor
binhpt
Posts: 14
Registered: ‎01-17-2012
Message 6 of 7 (1,122 Views)

Re: reading 2D information from a dwf file

06-26-2012 06:05 PM in reply to: binhpt

Please review this project : 

DWFToolkit-7.7\samples\DWFToolkit\W2dTest

You will find the a way to read dwf 2d  with read_test(...) function.

 

And open file W2dTest_vc100.vcxproj by notepad , you can find config for project .

Contributor
insiaiftiqhar
Posts: 19
Registered: ‎06-21-2012
Message 7 of 7 (1,104 Views)

Re: reading 2D information from a dwf file

07-03-2012 09:16 AM in reply to: binhpt

Thank you for your help. I had to change gears and start working within autocad using c# and autoLISP. I had looked into that sample before but I will look into it again.Would be nice to get it to work but writing autoLISP programs is working out quite well fro now.

Thanks again for your response.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!