Cachino King Posted February 21, 2022 Share Posted February 21, 2022 I need to get some data of models such as mesh, textures, coordinates, etc. I found that there is a function that can iterate over all objects: VCOM:VectorWorks:ISDK::ForEachObject. Does this "object" contain all of the models in the scene? I noticed that this function used like this: gSDK->ForEachObject( allObjects | descendIntoAll, MyCallBack, & data ); So what kind of data can I get from this "& data"? I also found these functions: VCOM:VectorWorks:ISDK::GetTextures, VCOM:VectorWorks:ISDK::GroupToMesh. Can these functions get the data what I want? Thank you! Quote Link to comment
Maarten DE Posted February 21, 2022 Share Posted February 21, 2022 virtual void ForEachObject( short traverseWhat, GS_ForEachObjectProcPtr action, void *actionEnv) action is called for all object that match the traverseWhat criteria, you need to filter the type that you want in that function. actionEnv can be used to pass on any kind of data you want from your "main" function to this action function. Here's a rough example, this is how you could get a list of all lines in the drawing. struct SMyLineData { std::vector<MCObjectHandle> listLines; }; void ApplyCritIsLine( Handle h, CallBackPtr, void *data ) { SMyLineData* lineData = (SMyLineData*)data; if ( gSDK->GetObjectTypeN( h ) == kLineNode ) lineData->listLines.push_back( h ); } void foo() { // save all lines in the drawing in lineData.listLines SMyLineData lineData; gSDK->ForEachObject( allObjects | descendIntoAll, ApplyCritIsLine, &lineData ); // do something with that list. } However, instead of saving it in a list, you could also do your operation directly in your action function. For resources, like texture definitions, you need to use gSDK->BuildResourceListN() or any of the other resource list functions/classes. But I'm not 100% sure this is actually what you need, do you want to go through the list of all objects inside a container? 1 Quote Link to comment
Cachino King Posted February 21, 2022 Author Share Posted February 21, 2022 I need to live sync the VW scene to another software. So I need to get the data for all the models in the scene includes mesh, textures, coordinates. And after some calculation VW scene should display on that software. So I just need to know the data of models. The scenes I need to synchronize should all be 3D scenes. I don't know how model data is stored, so I can't get such data I want. Also I need to export some .fbx files of these model to make sure it can be used by other software. Thank you! Quote Link to comment
Maarten DE Posted February 21, 2022 Share Posted February 21, 2022 Wow, be aware this is a very difficult thing to do, it will take some time to implement this. In VW, you have all sort of 3D geometry, al with different ways of saving their data and graphical attributes. So you'll need to cover all cases... And every year things get added/changed in VW, so maintening this will take some time too. I think it's best to contact VW inc for this, they might be able to tell you what other export menu commands do and tell you how to implement this correctly in a safe way. @Hugues @Vlado @SteveJ 1 Quote Link to comment
Cachino King Posted February 21, 2022 Author Share Posted February 21, 2022 3 minutes ago, Maarten DE said: In VW, you have all sort of 3D geometry, al with different ways of saving their data and graphical attributes. So you'll need to cover all cases... That's ... terrible. I didn't think it would be difficult... Thank you for your help. Quote Link to comment
JBenghiat Posted February 21, 2022 Share Posted February 21, 2022 Vectorworks is solids-based, not mesh-based, so if you need meshes you need to be doing object conversion, not just fetching object information. If you can use parasolids as your base data that might be easier. You can also automatically export various file formats via the SDK, but that won’t give you live updates. Are you doing this project as an end user or are you developing a commercial application? 1 Quote Link to comment
Cachino King Posted February 22, 2022 Author Share Posted February 22, 2022 11 hours ago, JBenghiat said: Vectorworks is solids-based, not mesh-based, so if you need meshes you need to be doing object conversion, not just fetching object information. If you can use parasolids as your base data that might be easier. You can also automatically export various file formats via the SDK, but that won’t give you live updates. Are you doing this project as an end user or are you developing a commercial application? I develop this project for myself, this task is very important for me. It is related to my graduation project. I noticed that there is a option: "File -> Export -> Export FBX". But I didn't find it in the Class Reference. Is this function used the same way as VCOM:VectorWorks:Filing:IImportExport3DS::Export? Quote Link to comment
Pat Stanford Posted February 22, 2022 Share Posted February 22, 2022 DoMenuTextByName('FBX Export',0); Will export an FBX file from Vectorscipt. VS.DoMenuTextByName('FBX Export',0) should work from Python but I didn't test. But it won't work in the background as it always opens the settings dialog box. 1 Quote Link to comment
Cachino King Posted February 23, 2022 Author Share Posted February 23, 2022 3 hours ago, Pat Stanford said: DoMenuTextByName('FBX Export',0); Will export an FBX file from Vectorscipt. VS.DoMenuTextByName('FBX Export',0) should work from Python but I didn't test. But it won't work in the background as it always opens the settings dialog box. Thank you. My project is completly coded by C++. Now I know that is difficult to export FBX directly. Quote Link to comment
JBenghiat Posted February 23, 2022 Share Posted February 23, 2022 You can look at the supported SDK export file formats in Interface/Filing: STL, 3DS, DWG, OBJ, SAT, and SketchUp. I don't know how many of those can happen without issuing a settings dialog, though. I would caution that live sync might be out of scope for a student project. Current live sync solutions have requited teams of developers, collaborating on both the export and import aide. 1 Quote Link to comment
JHangstoerfer Posted February 23, 2022 Share Posted February 23, 2022 (edited) @Cachino KingVectorworks Graphics Sync is what you want for a true live sync, assuming that you use VW2020 or higher. Look at Interfaces\VectorWorks\IVGS.h, you will need an extra header file for ::VGS::Operation because it's not included in the normal SDK. You'd have to contact VW and ask for access to the API. VGS is relatively straightforward, you get tessellated geometry, camera position, rudimentary materials (full materials with some more work), object instances and proper update events for all of it. Alternatively there is the Tesselator that you can use to get geometry from objects and their children. If you throw a layer handle into this tesselator it will export everything on that layer. The STessTraingle contains information about what is being tessellated and the object, material, triangles for it. Extra information like a transformation you can get from the object. This is more of a one-time export and you would need to detect any changes in the document yourself and then tessellate those parts again, which I'm not sure how to do. GS_TessellateIteratorProcPtr tesselationCallback = [](ETessProcReason reason, STessTraingle triangle, CallBackPtr cbp, void* pEnv) { YourExportContext* context = static_cast<YourExportContext*>(pEnv); switch (reason) { // collect data into context } }; YourExportContext context{}; TTesselator tesselator = gSDK->CreateTessellator(true); VectorWorks::STesselateOptions tesselationOptions{}; MCObjectHandle handleToRecursivelyTesselate; gSDK->TesselateObjectN(tesselator, tesselationOptions, handleToRecursivelyTesselate, tesselationCallback, &context); gSDK->DeleteTessellator(tesselator); Edited February 23, 2022 by JHangstoerfer 2 Quote Link to comment
Cachino King Posted February 24, 2022 Author Share Posted February 24, 2022 13 hours ago, JBenghiat said: I would caution that live sync might be out of scope for a student project. Current live sync solutions have requited teams of developers, collaborating on both the export and import aide. Yeah, that's quite difficult for me. The functions that implement FBX export do not exist. I looked up the file "MockSDK.h" and found a funtion "GetMesh". After some test, this function can let me get the vertexs of the mesh, and I found normal data, uv data all in the class "IMeshData". I just need to get these data and some material data and send these to another software. This part is relatively simple. Maybe there are very few kinds of polygons can convert to mesh. But I think it's enough to finish this task. Quote Link to comment
Cachino King Posted February 24, 2022 Author Share Posted February 24, 2022 9 hours ago, JHangstoerfer said: Vectorworks Graphics Sync is what you want for a true live sync, assuming that you use VW2020 or higher. Look at Interfaces\VectorWorks\IVGS.h, you will need an extra header file for ::VGS::Operation because it's not included in the normal SDK. You'd have to contact VW and ask for access to the API. VGS is relatively straightforward, you get tessellated geometry, camera position, rudimentary materials (full materials with some more work), object instances and proper update events for all of it. VGS is too difficult to me. I just need some mesh data and material data and send to my program. Although vectorwork use solid-base to save model data, I still want to convert solid to mesh. And I found the function can implement this. I read some guidance documents of my task that live sync they said is actually dynamic updating. If the scene changes in VW, the model information needs to be retransmitted. This method doesn't sound nearly as efficient as VGS, but it's easier to implement. Quote Link to comment
JHangstoerfer Posted February 24, 2022 Share Posted February 24, 2022 5 hours ago, Cachino King said: Yeah, that's quite difficult for me. The functions that implement FBX export do not exist. I looked up the file "MockSDK.h" and found a funtion "GetMesh". After some test, this function can let me get the vertexs of the mesh, and I found normal data, uv data all in the class "IMeshData". I just need to get these data and some material data and send these to another software. This part is relatively simple. Maybe there are very few kinds of polygons can convert to mesh. But I think it's enough to finish this task. GetMesh only works for kMeshNode objects. It doesn't work for solids. 4 hours ago, Cachino King said: VGS is too difficult to me. I just need some mesh data and material data and send to my program. Although vectorwork use solid-base to save model data, I still want to convert solid to mesh. And I found the function can implement this. I read some guidance documents of my task that live sync they said is actually dynamic updating. If the scene changes in VW, the model information needs to be retransmitted. This method doesn't sound nearly as efficient as VGS, but it's easier to implement. Where are you having troubles with VGS? I think it's the easiest of any of these methods. You get meshes for all objects including solids via VGS and their materials in easy to use formats. I can answer any questions you got about VGS. 1 Quote Link to comment
Cachino King Posted February 24, 2022 Author Share Posted February 24, 2022 33 minutes ago, JHangstoerfer said: GetMesh only works for kMeshNode objects. It doesn't work for solids. I used GroupToMesh first,then It crashes when it running to GetMesh. I used GetObjectType and found the object type is 40. The sheet of GetObjectType: kMeshNode 40 3D mesh object. 33 minutes ago, JHangstoerfer said: Where are you having troubles with VGS? I think it's the easiest of any of these methods. You get meshes for all objects including solids via VGS and their materials in easy to use formats. I can answer any questions you got about VGS. Thank you very much! There is too little documentation related to VGS, and I just found this: SDK:Using the VGS API for Vectorworks model export and live sync I tried to download the VGS Sample, but I didn't know how to use it. After I put those two files in the "Plug-Ins", I didn't see anything about VGS in the "Tools --> Workspaces --> Edit Workspace". Quote Link to comment
Cachino King Posted February 24, 2022 Author Share Posted February 24, 2022 Okay, I just found the VGS plugin. But I still don't understand why the GetMesh will cause my program crashed. //this function used like this: /* gSDK->ForEachObject(allObjects | descendIntoAll, CollectMesh, this); */ void CollectMesh(Handle h, CallBackPtr cbp, void* env) { // convert solid to 3DPolygons Handle meshH = gSDK->ConvertTo3DPolygons(h); // convert polygons to mesh short meshErrorType = gSDK->GroupToMesh(meshH); if (meshErrorType == 0) { VectorWorks::IMeshData **thisMesh; bool isGetMesh = gSDK->GetMesh(meshH, thisMesh);///crashed here //(**thisMesh).GetVertexPosition(vertexNum - 2, vertexs); } } Quote Link to comment
Vectorworks, Inc Employee Vlado Posted February 24, 2022 Vectorworks, Inc Employee Share Posted February 24, 2022 @Cachino King It looks like you need to you use the ISDK function: gSDK->TesselateObject It will give you the faces and texture mapping of the object you provide. Essentially, it's like rendering the object, only it renders into a callback. Send me an email to vstanev@vectorworks.net and I can send you some code snippets. 1 Quote Link to comment
Cachino King Posted February 25, 2022 Author Share Posted February 25, 2022 5 hours ago, Vlado said: Send me an email to vstanev@vectorworks.net and I can send you some code snippets. Thank you! I already sent you an email. Thank you very much! Quote Link to comment
JBenghiat Posted February 27, 2022 Share Posted February 27, 2022 On 2/24/2022 at 4:59 AM, Cachino King said: VectorWorks::IMeshData **thisMesh; bool isGetMesh = gSDK->GetMesh(meshH, thisMesh);///crashed here To answer your specific question, you want to pass the address of the pointer, rather than defining a double pointer VectorWorks::IMeshDataPtr thisMesh; bool isGetMesh = gSDK->GetMesh( meshH, & thisMesh ); 1 Quote Link to comment
Cachino King Posted February 28, 2022 Author Share Posted February 28, 2022 On 2/27/2022 at 12:07 PM, JBenghiat said: To answer your specific question, you want to pass the address of the pointer, rather than defining a double pointer That's quite helpful. I'll try to keep going this task. Thank you very much! Quote Link to comment
Vectorworks, Inc Employee Vlado Posted March 3, 2022 Vectorworks, Inc Employee Share Posted March 3, 2022 Here is a little random information on textures and images. Textures can be taken from the shaders: https://developer.vectorworks.net/index.php/SDK:Using_Shader_Records As for the images itself, there is a class VWFC::VWObjects::VWBitmapObj but I’m not sure how useful it is. I would rather look into VCOM interface VectorWorks::Imaging::ICompressedImage for example. See the others in this namespace They are located in the SDK, and automatically/should be included in your project: \SDKLib\Include\Interfaces\VectorWorks\Imaging You can use it like this: using namespace VectorWorks::Imaging; ICompressedImagePtr image( IID_CompressedImage ); // create an instance Image->CreateFromObject( h ); 1 Quote Link to comment
Cachino King Posted March 4, 2022 Author Share Posted March 4, 2022 11 hours ago, Vlado said: Here is a little random information on textures and images. Emmmm, I'm still understanding TesselateObject. There are so many problems I don't know how to describe. Maybe I need few days to read the code. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.