Google SketchUp SDK for FreeBASIC windows 32/64-Bit

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
D.J.Peters
Posts: 7825
Joined: May 28, 2005 3:28

Google SketchUp SDK for FreeBASIC windows 32/64-Bit

Postby D.J.Peters » Mar 13, 2015 19:47

Google SketchUp SDK for FreeBASIC windows 32/64-Bit

Last night I rewrote all stuff for FreeBASIC documentation are included.

Download: fbslapi.zip ~7.4MB

You can create,read,modify and save *.skp SketchUp models.

Or you can write file Importers and Exporters for SketchUp.

Joshy

Simple test of my translated SDK files.

Code: Select all

#include once "slapiall.bi"

'Always initialize the API before using it
SUInitialize()

' Load the model from a file
dim as SUModelRef model = SU_INVALID
' It's best to always check the return code from each SU function call.
if (SUModelCreateFromFile(@model, "model.skp") <> SU_ERROR_NONE) then
  SUTerminate()
  print "error: UModelCreateFromFile !"
  beep: sleep: end 1
end if

' Get the entity container of the model.
dim as SUEntitiesRef entities = SU_INVALID
if (SUModelGetEntities(model, @entities) <> SU_ERROR_NONE) then
  SUTerminate()
  print "error: SUModelGetEntities !"
  beep: sleep: end 1
end if

' Get all the faces from the entities object
dim as size_t faceCount = 0
SUEntitiesGetNumFaces(entities, @faceCount)
if (faceCount > 0) then
  dim as SUFaceRef faces(faceCount)
  SUEntitiesGetFaces(entities, faceCount, @faces(0), @faceCount)
  ' Get all the edges in this face
  for i as size_t = 0 to faceCount-1
     
    dim as size_t edgeCount = 0
    SUFaceGetNumEdges(faces(i), @edgeCount)
    if (edgeCount > 0) then
      dim as SUEdgeRef edges(edgeCount)
      SUFaceGetEdges(faces(i), edgeCount, @edges(0), @edgeCount)
      ' Get the vertex positions for each edge
      for j as size_t = 0 to edgeCount-1
        print "face(" & i & ").edge(" & j & ")"
        dim as SUVertexRef startVertex = SU_INVALID
        dim as SUVertexRef endVertex = SU_INVALID
        SUEdgeGetStartVertex(edges(j), @startVertex)
        SUEdgeGetEndVertex(edges(j), @endVertex)
        dim as SUPoint3D edgeStart
        dim as SUPoint3D edgeEnd
        SUVertexGetPosition(startVertex, @edgeStart)
        SUVertexGetPosition(endVertex, @edgeEnd)
        print edgeStart.x,edgeStart.y,edgeStart.z
        print edgeEnd.x,edgeEnd.y,edgeEnd.z
      next
    end if
  next
end if

' Must release the model or there will be memory leaks
SUModelRelease(@model)
' Always terminate the API when done using it
SUTerminate()
sleep

Image
Tyr_Anassazi
Posts: 26
Joined: Jul 01, 2013 15:01
Location: Russia, Novosibirsk
Contact:

Re: Google SketchUp SDK for FreeBASIC windows 32/64-Bit

Postby Tyr_Anassazi » Mar 16, 2015 5:42

Wow! Very interesting! I try it for sure.

Return to “Libraries”

Who is online

Users browsing this forum: No registered users and 19 guests