Giter Club home page Giter Club logo

sketchupnet's Introduction

SketchUpNET

C++/CLI API Wrapper for the Trimble(R) SketchUp(R) C API. http://www.sketchup.com/intl/en/developer/api-terms-of-service.pdf

This library adds .NET support to the existing SketchUp C-API. It makes most SketchUp C-API features available in .NET and therefore accessible in C# or VB applications. You can download a pre-built release of the library or build it yourself from scratch.

Code-Examples

This Repo contains three sample projects using SketchUpNET in C#.NET:

  • SketchUpForDynamo: An Autodesk's(R) Dynamo Node Package allowing you to read/write SketchUp files from Dynamo.
  • SketchUpForGrasshopper: A Set of Components for McNeel's(R) Grasshopper(R) allowing you to read/write SketchUp files from GH.
  • SketchUpNETConsole: A sample C# console application using SketchUpNET.

If you want to build your own application using the SketchUp API take the following steps:

Loading a Model

SketchUpNET.SketchUp skp = new SketchUp();
skp.LoadModel("myfile.skp", true);
foreach (var srf in skp.Surfaces) {
  // do something with your surfaces
}

Saving a Model

skp.WriteNewModel("filename.skp");

Converting a Model

SketchUpNET.SketchUp skp = new SketchUp();
skp.SaveAs("old-file.skp", SKPVersion.V2020, "new-file.skp");

Writing a Surface to a File

SketchUpNET.SketchUp skp = new SketchUpNET.SketchUp();
skp.Layers = new List<Layer>() { new Layer("Layer0") };
skp.Surfaces = new List<Surface>();
skp.Curves = new List<Curve>();
skp.Edges = new List<Edge>();
List<SketchUpNET.Vertex> Verticies = new List<SketchUpNET.Vertex>();

SketchUpNET.Loop OuterEdges = new SketchUpNET.Loop();
OuterEdges.Edges = new List<Edge>();
{
  OuterEdges.Edges.Add(new SketchUpNET.Edge(new Vertex(0, 0, 0), new Vertex(500, 0, 0), "Layer0"));
  OuterEdges.Edges.Add(new SketchUpNET.Edge(new Vertex(500, 0, 0), new Vertex(500, 500, 0), "Layer0"));
  OuterEdges.Edges.Add(new SketchUpNET.Edge(new Vertex(500, 500, 0), new Vertex(0, 500, 0), "Layer0"));
  OuterEdges.Edges.Add(new SketchUpNET.Edge(new Vertex(0, 500, 0), new Vertex(0, 0, 0), "Layer0"));
}

List<Loop> InnerLoops = new List<Loop>();
{
  SketchUpNET.Loop InnerEdges = new SketchUpNET.Loop();
  InnerEdges.Edges = new List<Edge>();
  InnerEdges.Edges.Add(new SketchUpNET.Edge(new Vertex(100, 100, 0), new Vertex(400, 100, 0), "Layer0"));
  InnerEdges.Edges.Add(new SketchUpNET.Edge(new Vertex(400, 100, 0), new Vertex(400, 400, 0), "Layer0"));
  InnerEdges.Edges.Add(new SketchUpNET.Edge(new Vertex(400, 400, 0), new Vertex(100, 400, 0), "Layer0"));
  InnerEdges.Edges.Add(new SketchUpNET.Edge(new Vertex(100, 400, 0), new Vertex(100, 100, 0), "Layer0"));
  InnerLoops.Add(InnerEdges);
}

SketchUpNET.Surface s = new SketchUpNET.Surface(OuterEdges, InnerLoops);
skp.Surfaces.Add(s);

skp.WriteNewModel(@"TempModel.skp");

Requirements

If not installed you might requires Visual C++ Redistributable Packages for Visual Studio https://www.microsoft.com/en-sg/download/details.aspx?id=40784

The library requires the SketchUp C API which is part of the package.

nuget Binaries

SketchUpNET is available as a precompiled binary on nuget: https://www.nuget.org/packages/SketchUpNET/

sketchupnet's People

Contributors

moethu avatar tonyhuangyj avatar keqli avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.