Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A .NET library and a command line utility for converting BCF (Building Collaboration Format) files into json and vice versa.

License

NotificationsYou must be signed in to change notification settings

bimspot/bcf-toolkit

Repository files navigation

This C# NuGet library allows you to easily build up and convert data into BCFfiles. It gives you a straightforward API to build your BCF objects exactly howyou want in your order.

You can install theBcfToolkit library via NuGet Package Manager or by addingit to your project's .csproj file.

nuget install Smino.Bcf.Toolkit

Usage

Creating BCF objects

To create a BCF Model,BcfBuilder class can be used. Then, variousfunctions provided by the builder can be used to fulfill the BCF model objects.

Here are some examples:

usingBcfToolkit.Builder.Bcf30;varbuilder=newBcfBuilder();varbcf=builder.AddMarkup(m=>m.SetTitle("Simple title").SetDescription("This is a description").AddLabel("Architecture").SetPriority("Critical").SetTopicType("Clash").SetTopicStatus("Active").AddComment(c=>c.SetComment("This is a comment").SetDate(DateTime.Now).SetAuthor("jimmy@page.com")).AddViewPoint(v=>v.SetPerspectiveCamera(pCam=>pCam.SetCamera(cam=>cam.SetViewPoint(10,10,10))),snapshotData))// Provide a snapshot data here.SetExtensions(e=>e.AddPriority("Critical").AddPriority("Major").AddPriority("Normal").AddPriority("Minor").AddTopicType("Issue").AddTopicType("Fault").AddTopicType("Clash").AddTopicType("Remark").AddTopicLabel("Architecture").AddTopicLabel("Structure").AddTopicLabel("MEP")).SetProject(p=>p.SetProjectId("projectId").SetProjectName("My project")).SetDocumentInfo(dI=>dI.AddDocument(d=>d.SetFileName("document.pdf").SetDescription("This is a document"))).Build();

TheBcfBuilder class can also consume BCF files as a stream and build up themodel objects.

usingBcfToolkit.Builder.Bcf30;awaitusingvarstream=newFileStream(source,FileMode.Open,FileAccess.Read);varbuilder=newBcfBuilder();varbcf=awaitbuilder.BuildFromStream(stream);

The default builders can be used if the user prefers not to deal with fillingthe required fields. Thebuilder.WithDefaults() function serves this.However in certain cases the user may need to replace the component IDs of IFCobjects with the actual GUIDs during the build process.

usingBcfToolkit.Builder.Bcf30;varbuilder=newBcfBuilder();varbcf=builder.WithDefaults().Build();

Using BCF worker

TheBCF worker is designed to facilitate the conversion ofBCF files toJSON and vice versa using predefined workflows. The appropriate workflow isselected based on the file extensions of the source and target. For example, ifthe source file ends with.bcfzip, theBcfZipToJson converter is used.

Basic conversion

usingBcfToolkit;varworker=newWorker();awaitworker.Convert(source,target);

Direct converter usage

You can also call specific converters directly for converting betweenBCF andJSON.

BCF to JSON
usingBcfToolkit.Converter.Bcf30;varconverter=newConverter()converter.BcfZipToJson(source,target);
JSON to BCF
usingBcfToolkit.Converter.Bcf30;varconverter=newConverter()converter.JsonToBcfZip(source,target);

Stream-based conversion

The library supports consumingBCF archives as streams. The code determinesthe version of the source and delegates the conversion to the appropriate nestedconverter object, converting it toBCF 3.0 as needed.

BCF from Stream
usingBcfToolkit;awaitusingvarstream=newFileStream(source,FileMode.Open,FileAccess.Read);varworker=newWorker();varbcf=awaitworker.BcfFromStream(stream);
BCF to Stream

The worker can generate a file stream from a specifiedBCF object, convertingit to the desired version.

IMPORTANT: The user is responsible for disposing of the stream after use.

usingBcfToolkit;varworker=newWorker();varstream=awaitworker.ToBcf(bcf,BcfVersionEnum.Bcf30);// custom code to use the stream...awaitstream.FlushAsync();
Specifying Output Stream

You can define an output stream to which the conversion results will be written.

usingBcfToolkit;varworker=newWorker();varoutputStream=newMemoryStream();worker.ToBcf(bcf,BcfVersionEnum.Bcf30,outputStream);// custom code to use the stream...awaitoutputStream.FlushAsync();

Cancellation Support

The worker supportsCancellationToken to allow for the cancellation ofasynchronous operations.

usingBcfToolkit;varworker=newWorker();varoutputStream=newMemoryStream();varsource=newCancellationTokenSource();vartoken=source.Token;worker.ToBcf(bcf,BcfVersionEnum.Bcf30,outputStream,token);// custom code to use the stream...awaitoutputStream.FlushAsync();

File Structure

The structure of the BCF is perthe standard. There is, however, nostandard for the JSON format other than theBCF API specification.

The naming convention for this converter is taken from the BCF API, but theoutput is opinionated:

There is one JSON for everyMarkup and within the structure of the informationfollows that of the XML. There are no separate files for screenshots, they arebase64 encoded in the fieldsnapshot_data of theViewpoint. The files arenamed using theuuid of theTopic within.

|- json  |- 2ea98d1e-77ae-467f-bbc9-1aed1c1785f6.json  |- 3395f1b1-893f-4ca0-8b7d-c2d17d7a9198.json  |- c799e527-a413-43f8-8871-80918a52b0f0.json  |- ...  |- project.json  |- extensions.json  |- documents.json  |- version.json

Development

The development of the tool is ongoing, the table below shows the currentlycompleted features.

BCF 2.0BCF 2.1BCF 3.0JSON 2.0JSON 2.1JSON 3.0
BCF 2.0
BCF 2.1X
BCF 3.0X
JSON 2.0
JSON 2.1X
JSON 3.0X

The models for the BCF in-memory representation were auto-created from thelatest XSDs using theXmlSchemaClassGenerator.

~ dotnet tool install --global dotnet-xscgen~ xscgen -n [namespace] version.xsd

To publish, run the script atdist/publish.sh.

Contribution

Code style guide can be found in thebcf-toolkit.sln.DotSettings file.

About

A .NET library and a command line utility for converting BCF (Building Collaboration Format) files into json and vice versa.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp