moethu / sketchupnet Goto Github PK
View Code? Open in Web Editor NEWSketchUp C# API - A C++/CLI API Wrapper for the Trimble(R) SketchUp(R) C API
License: MIT License
SketchUp C# API - A C++/CLI API Wrapper for the Trimble(R) SketchUp(R) C API
License: MIT License
For some reason some skp files are perfectly readable except for the fact that it shows 0 surfaces, all the other stuff is there, like components, instances, materials, etc. But for some reason some files return 0 surfaces.
static System::String^ GetString(SUStringRef name)
{
size_t name_length = 0;
SUStringGetUTF8Length(name, &name_length);
if (name_length==0) {
return System::String::Empty;
}
char* name_utf8 = new char[name_length + 1];
SUStringGetUTF8(name, name_length + 1, name_utf8, &name_length);
SUStringRelease(&name);
System::String^ s1= gcnew System::String(name_utf8,0,name_length,System::Text::Encoding::UTF8);
//System::String^ s2= gcnew System::String(name_utf8);
return s;
}
System::String^ s2= gcnew System::String(name_utf8);
If you are in use other language,s2 return error string. replace it with
System::String^ s1= gcnew System::String(name_utf8,0,name_length,System::Text::Encoding::UTF8);
Is support writing components and groups when creating a new model?
The WriteNewModel
method seems to handle only faces, edges, and curves.
SketchUpNET/SketchUpNET/SketchUpNET.cpp
Lines 342 to 344 in eed3cd9
Add support for latest sketchup versions (eg. 2019 and 2020)
Hi, is it possible to filter imported geometry in dynamo by layer name?
Hi , i have developed a tool and it worked on my machine , but when i transferred the build process to the server , i got FileNotFoundException on sketchupNet.dll later i tried to reinstall the runtime witch is given in a Requirements but aint no effect on this. So try after try i managed to clone this whole repository and noticed tha c++ development package was needed , after installing it now it works on the server.
So i dont know what exactly is missing. but maybe if it would be a good test to create clean windows Virtual machine and try to figure out what exactly is needed for the full dependency list.
Hi there!
Thanks for the great work! I tried to get this working and have been able to build and run a console .NET app that uses your SketchUpNET library, but I have not been able to load a .SKP file that was created with a recent version of sketchup.
I guess this is probably because the library is implemented for an outdated sketchup api version, right?
Is there any chance you could provide it for the current version of sketchup?
Or could I send you the .SKP file so that you can tell me what I am doing wrong?
I would also be ok to pay you as an compensation for your efforts if you can help...
Thanks and best regards.
Florian
Hello Maximilian,
Is it at all possible to retain material and texture mapping data through sketchup - dynamo - revit?
There seems to be some issue with the SketchUpNET.dll file when trying to run the Grasshopper file. @moethu can you please try rebuilding or modifying it so that it can run with Grasshopper for Rhino 6? I'm interested in contributing to the Grasshopper part of this project, but I'm no good with C++ at all. Thanks!
my project c# console
i add the library on project and build success but when run the project get the error
could not load file or assembly.....
i change build mode x86 x64 any cpu
downloaded files SketchUpNET build 180818.zip
Hello Maximilian,
I am wondering if it would be possible to load sketchup components as solids, or at least as @L2 lists of surfaces. Right now the model comes in as a large list of surfaces. Joining surfaces by polysurfaces and making solids out of those to be exported into revit only works as long as no geometry intersects.
Importing something such as this, and having each object show up requires importing each component separately and moving them into the same position within Revit:
Having that feature would enable me to be to create solids out of sketchup models (such as furniture made by a landscape architect in sketchup, where the seat of the chair (a component) intersects the arms of the chair (another component)). By sorting each component into its own list, we would be able to bring in those components as individual solids into our revit environment.
If you think this is doable, I would love to work with you on this and try and write it.
Thanks,
kv2
As the title already says, it's not possible to load models when the filepath (filename and folderpath) contains special (in this case german) characters (ä, ö, ü, ß, ...). I'm using this library in a VB.NET WPF application and apart from this it works perfectly fine. But i couldn't find a solution to this on my applications side.
Is it possible to fix this problem? I'm not that experienced when it comes to C/C++...
Each vertice that is part of a surface which is part of an instance you can use .GetTransformed on and you get the correct position of the vertice to build your mesh but some components aren't part of an instance and contain surfaces that aren't part of an instance so how do you go about positioning those vertices in the correct place?
Sorry I have to ask it here but I don't know where else to go, the documentation on SketchUp file structures is very limited.
Hi,May I know how to obtain the texture coordinates of each face.
I try it in 2017,but can't load skp file.
Cannot not compile due to missing slapi.lib
Hi
Is it possible to update the nuget version to 1.7.3 and fix the problem below?
I have exactly the same problem as #51
by either using:
So I can't get it to work, no matter what version I use.
I use VS2022.
Thanks in advance!
Im trying to test this lib. on 4.8 .net framework and get:
System.BadImageFormatException: 'Could not load file or assembly 'SketchUpNET, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.'
How to solve this, as 4.0 .net framework is no longer available for download
Scene:
SketchUp skp = new SketchUp();
var bRtn = skp.LoadModel(“c:\TestModel - 副本.skb”, true);
but return false。
in bool LoadModel(System::String^ filename, bool includeMeshes),
Fix it:
#pragma region Convert System::String to const char* by utf8 encoding
array<unsigned char>^ bytes = System::Text::Encoding::UTF8->GetBytes(filename);
char* path = new char[bytes->Length + 1];
path[bytes->Length] = 0;
int i = 0;
for each(unsigned char c in bytes) {
path[i++] = c;
}
//complete to delete path.
#pragma endregion
//msclr::interop::marshal_context oMarshalContext;
//const char* path = oMarshalContext.marshal_as<const char*>(filename);
SUInitialize();
Hi,
is there any way to get in contact with you? Sorry for misusing an Issue for this but I failed to find another way...
Hi, I've tried to create new layers and groups with the package 1.7.2 (NuGet) and 1.7.3 (latest release)
but none of them work for the functionalities,
although I've successfully wrote a file with geometries by following the tutorial,
the layer of each geometry remained on "Layer0",
how can I solve this?
Thank you for sharing your library, this helps me a lot since I have no experience in C API development.
Thank you :]
I am getting weird results when trying to create a surface with a hole in it. In order to test my code, I created a square with a square hole in Sketchup. I opened the file and created code from all the values in the opened file (second part of code.txt). Finally I just tried opening the file and saving it and I get the same results. The shape is merged together.
Any suggestions?
Thank you
SketchUpNET.SketchUp skp = new SketchUpNET.SketchUp();
if (skp.LoadModel("Input.skp"))
{
skp.WriteNewModel("new.skp", SKPVersion.V2017);
}
I have a SKP file with Dynamic Component and some Attributes like Name, Summary, Description, lenX, lenY, lenZ...etc information inside.
Could you support to read this information? thank you
GH Extrusions for surfaces seem to be off, they'll need to be fixed.
SketchUp makes use of scenes to hide and show a specified set of layers. It would be nice if there was a reference to these scenes.
no link FaceBackMaterial in group?
//Function is
//static Surface^ FromSU(SUFaceRef face, bool includeMeshes, System::Collections::Generic::Dictionary<String^, Material^>^ materials)
SUMaterialRef mback = SU_INVALID;
SUFaceGetBackMaterial(face, &mback); //Error mback is 0x00
SUStringRef mbackNameRef = SU_INVALID;
SUStringCreate(&mbackNameRef);
SUMaterialGetName(mback, &mbackNameRef);
//test file is
1.zip
Hi , is there a way to change file unit system to milimeters, as now on default it is set to meters
i found a ref how to implement it in c but dont have understanding how to fill in in a wrapper
https://extensions.sketchup.com/developers/sketchup_c_api/sketchup/struct_s_u_options_provider_ref.html
I wanted to compile this library into unity, but now I'm having trouble.ask for help
AFAIK SketchUpNET only works on Windows right? You are using a vcxproj project, that has C++ sources.
This articles discusses how to port a C++ project to .NET Core: https://docs.microsoft.com/en-us/dotnet/core/porting/cpp-cli. However, it notes that C++/CLI support for .NET Core is Windows only. Support for macOS or Linux isn't probably to come (for a long time).
They recommend using platform invoke to support .NET core. What's your view on this? Do you have any plans on making it work for .NET Core (and thereby Linux and macOS)?
IDE:VS2022(x64 17.1)
Package:SketchUpNET 1.7.2 from Nuget with Nuget Package Manager
Project:both Console(.Net Core but change targetframework .net 6.0 to .net462) and Console(.Net Framework 4.6.2)
Code:
`using System;
using SketchUpNET;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
SketchUp skp = new SketchUp();
if (skp.LoadModel(@"E:\test.skp"))
{
Console.WriteLine("TEST");
}
}
}
}`
Error:Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly "SketchUpNET.dll" or it's referrences.
Is it possible to create a NuGet package for this awesome library?
You do it well,The idea very good,I hope join you,maybe?
Hi
I have been trying to use your library and have found that my materials are not being saved to the SKP file.
I have created the following as an example. My main code creates faces etc but I removed them for this example.
I would assume the Material called "MyColor" would be saved to the SKP File.
static void test3()
{
Color c = new Color(255, 0, 0, 255);
Material backMaterial = new Material("MyColor", c, false, 1, true, false, null);
SketchUpNET.SketchUp skp = new SketchUpNET.SketchUp();
if (skp.LoadModel(@"c:\temp\chris1.skp", true) == false)
{
return;
}
skp = new SketchUpNET.SketchUp();
skp.Surfaces = new List<SketchUpNET.Surface>();
skp.Edges = new List<SketchUpNET.Edge>();
skp.Curves = new List<SketchUpNET.Curve>();
skp.Groups = new List<SketchUpNET.Group>();
skp.Instances = new List<Instance>();
skp.Components = new Dictionary<string, Component>();
skp.Layers = new List<SketchUpNET.Layer>();
skp.Layers.Add(new SketchUpNET.Layer("Chris"));
skp.Materials = new Dictionary<string, Material>();
skp.Materials.Add("Red", backMaterial);
System.IO.File.Delete(@"c:\temp\chris1.skp");
skp.WriteNewModel(@"c:\temp\chris1.skp");
}
Have I done something wrong?
I am using SketchUpNET-build-180818 (precompiled binaries)
Chris
Hi , i wonder is there a function to draw 3d text or any other text in 3D space ?
VS 2022 using x64
I installed 1.7.2 via Nuget and tried to run your example code. I get an exception
"System.IO.FileNotFoundException: 'Could not load file or assembly 'SketchUpNET.dll' or one of its dependencies. The specified module could not be found.'"
I tried deleting the reference and downloading the 1.7.3 dll and referencing that instead. Same error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.