I want to integrate my Delphi DX10 application with Sketchup. My application is a Product Configurator, at this moment specialized in furniture industry.


I want to integrate my Delphi DX10 application with Sketchup. My application is a Product Configurator, at this moment specialized in furniture industry.

What I need is create a .skp file with the piece of furniture currently editing on my application and after open this file with Sketchup. The user can make modifications in Sketchup and after close it my application will modify the data of the piece of furniture, accordingly with the modifications in sketchup file.

I know two ways for treat of do this.

The first consist in create from my app, a script in Ruby that I can pass as parameter to Sketchup. This sounds well but the problem is about select a format to export later the modified project. Which format is better for warranting that the data readed, have the precision of the corresponding to the Ruby script I've sent?


The second way consist in make use of the SDK of Sketchup. Is supposed that with this tool I can create, from my application a .skp file, and of course, that after the modifications I can read the resulting .skp file too. The problem here is: my application is realized with Delphi, and the examples of the SDK are for C++. Which language should I use for this integration? Delphi or C++? If I use C++, how to integrate the C++ module with Delphi. Can I use as a .bpl unit or is better insert the data into the database from C++ and use it with Delphi after?


Any one in the group has experience in a similar integration?

I will thank all the stories, advices, and any input.

Thanks to all in advance!!

Comments

  1. That really depends on how carefully the original SDK has been designed. If every care has been taken to ensure it will be interoperable, then it's a fairly easy one. Otherwise, you may go for a different route and expose a C++ DLL of your own which wraps the original SDK and plays ball with Delphi.

    ReplyDelete
  2. Andrea Raimondi
    Yes! You are alrigth. This may be a variant of the second way. But what I'm asking here is if anyone have a concrete experience, with this SDK or with a similar situation.

    I'm going to take into account your point of view. What's your concrete experience integrating/translating this type of SDKs with Delphi in any form?

    Thank you Andrea!

    ReplyDelete
  3. I have had several times, in the past, to deal with DLLs made in C++.
    As I said, this is a mine field and each case is its own. C++ has name mangling for functions, so an appropriate SDK should have proper exported names to start with. Ideally, it would also use "uncontroversial" types, thus avoiding stuff like void** or other silliness-es like that.

    Also, always ideally, the calling convention would be explicitly specified.
    File names can be a real mess, especially now, because they may be assuming that their product is only used in English. If that is so, then you're looking at a world of hurt.

    As I said, each SDK is its own game and you really need to dig a bit to understand which game they're playing.

    ReplyDelete
  4. go with the script in Ruby, the alternative is a rabbit hole, you'll be spending weeks in "perfecting" your SDK, you'll probably end up rewriting it as you learn new and better ways to code it;

    the script approach will be fast, and you can have small increments faster and cheaper overall.

    ReplyDelete
  5. Yes what Dorin said. Choose ANY script language. What you need can be done easily in a script language. Delphi is not a script language.

    Ruby is the way to go because it's what the Sketchup authors support.

    Trying to use a C/C++ plugin API to build stuff with Delphi is a recipe for pain unless you're equally and fully capable of writing the whole thing in C++ and just wanted to make it more hard on yourself.

    ReplyDelete
  6. Dorin Duminica
    Thank you Dorin for your opinion, but this solve only the first part of the problem.

    Sketchup don't produce scripts!!!

    I can generate a script on Ruby, from Delphi, that Sketchup can interpret generating the piece of forniture inside.

    The user can now modify this piece.

    Here come the problem. Sketchup have a lot of types of exportation, but nothing about scripts. I can't program, from inside Scketchup, the manner of export the data. And I can't find a method of exportation that respect the data that I was "created/imported" with the Ruby script.

    That's the problem in the way of the scripts.

    ReplyDelete
  7. Sorry for my late answer but I just noticed this post while searching for Delphi+Sketchup.
    I do use the C++ sketchup SDK, but only to read skp files(SkpReader). It is straightforward because they have a .tlb file in the SDK, so you don't have to translate anything, just import the Type Library and then you have access to the whole SDK with

    readersdk := CreateComObject(CLASS_ReaderApplication);

    That said, I searched for Delphi+Sketchup because I learn that the C++ SDK, which was flagged as "deprecated" since 2014, will be removed in the next SDK release. It was replaced by a C API, and, like you, I wonder if someone has experience with Delphi+Sketchup, but with the new C API.

    ReplyDelete
  8. Damien Demars

    Anyway, thanks for your response.
    Finally we change the strategy for this section of the project. We have discovered that there are an alternative to all of this.

    OpenSCAD: is a language to draw 3D objects. In some tools the actions you make in a graphic environment are treated internaly as a "Tree of operations". This tree is an structure in which each operation is reflected in a stable position and related to all other operations.

    As you can see, in a Product Configurator based in a tree structure sound very easy translate this "product-tree" in a "draw-tree". And the latest handicap is a good language to express this.

    Well. OpenSCAD seems to be a very expresive language and admits command line parameters that allow us to instruct the IDE of OpenSCAD to do operations without the intervention fo the final user.

    We can do things like:
    - Generate in a file the instructions to the 3D graphic.
    - Call OpenSCAD IDE indicating that shall....
    - Draw using the content o this file
    - Export a Graphic file.
    - Export a .STL file
    - Close OpenSCAD
    - Load into our Database the generated files and show the graphic inside our application.

    We've see that OpenSCAD is a live and very dinamic project. Some things are still in development, but the advantage of count with a clear objetives and a good documentation as target, speaks of a good option. I think.

    ReplyDelete

Post a Comment