Hi.
First of all, this is my first post in this forum. I've been a lurker for many years and now I'm getting my first hands on ruby development. This community has been very helpful to me these past few years. ![=) 😃](https://community.sketchucation.com/assets/plugins/nodebb-plugin-emoji/emoji/android/1f603.png?v=3orp1bvic7q)
Now onto the topic.
I'm currently using sketchup as a development tool for a VR experience based in historical reconstruction in Unreal Engine 4. All the assets are then exported to max and given the proper treatment for realtime.
Thing is, all the measurements and positioning of objects, mainly architectonical pieces are based off real world sizes and layout. Due to this, the level assembly inside UE4 becomes nigh impossible due to the oblique angles and no vertex snapping in repeatable pieces in the editor.
To this end, I'm using sketchup itself as a level assembly tool. All objects are given an impostor component inside sketchup with the same pivot. I'm then exporting the whole thing to 3ds max and using a max script like this:
rollout test "Copy to UE4"
(
label packagelabel "Folder Path" style_sunkenedge;false width;180 height;20
edittext packagename "" width;180
label objectlabel "Object Name" style_sunkenedge;false width;180 height;20
edittext objectname "" width;180
button btnCopy "Copy" width;180
fn round_to val =
(
(floor (val + 0.5))
)
on btnCopy pressed do
(
clipboardstring=""
clipboardstring += ("Begin Map")
clipboardstring += ("\n"+" Begin Level")
for obj in selection do
(
clipboardstring += ("\n"+" Begin Actor Class=StaticMeshActor Name=" + objectname.text + " Archetype=StaticMeshActor'/Script/Engine.Default__StaticMeshActor'")
clipboardstring += ("\n"+" Begin Object Class=StaticMeshComponent Name=StaticMeshComponent0 ObjName=StaticMeshComponent0 Archetype=StaticMeshComponent'/Script/Engine.Default__StaticMeshActor;StaticMeshComponent0'")
clipboardstring += ("\n"+" End Object")
clipboardstring += ("\n"+" Begin Object Name=StaticMeshComponent0")
clipboardstring += ("\n"+" StaticMesh=StaticMesh'" + packagename.text + objectname.text + "." + objectname.text + "'")
clipboardstring += ("\n"+" StaticMeshDerivedDataKey=\"STATICMESH_34081786561B425A9523C94540EA599D_359a029847e84730ba516769d0f19427_08B81D3F4753513B93E720832A7E9708000000000100000001000000000000000000803F0000803F00000000000000000000344203030300000000\"")
clipboardstring += ("\n"+" RelativeLocation=(X=" + obj.transform.position.x as string)
clipboardstring += (",Y=" + ((obj.transform.position.y) - (obj.transform.position.y) - (obj.transform.position.y)) as string)
clipboardstring += (",Z=" + obj.transform.position.z as string)
clipboardstring += (")")
clipboardstring += ("\n"+" RelativeRotation=(Pitch=" + (round_to (obj.rotation.x_rotation) as integer) as string)
clipboardstring += (",Yaw=" + (round_to ((obj.rotation.z_rotation * -1)) as integer) as string)
clipboardstring += (",Roll=" + (round_to (obj.rotation.y_rotation) as integer) as string)
clipboardstring += (")")
clipboardstring += ("\n"+" RelativeScale3D=(X=" + obj.transform.scale.x as string)
clipboardstring += (",Y=" + obj.transform.scale.y as string)
clipboardstring += (",Z=" + obj.transform.scale.z as string)
clipboardstring += (")")
clipboardstring += ("\n"+" End Object")
clipboardstring += ("\n"+" StaticMeshComponent=StaticMeshComponent0")
clipboardstring += ("\n"+" RootComponent=StaticMeshComponent0")
clipboardstring += ("\n"+" ActorLabel=\"" + objectname.text + "\"")
clipboardstring += ("\n"+" End Actor")
)
clipboardstring += ("\n"+" End Level")
clipboardstring += ("\n"+"Begin Surface")
clipboardstring += ("\n"+"End Surface")
clipboardstring += ("\n"+"End Map")
SetClipBoardText (clipboardstring as string)
)
)
createDialog test 200 160 fgcolor;Black
This code from another user in the UE forums, generates the coordinates of all selected objects to clipboard and allows you to just paste it into UE4. I've made a few modifications to it, but it's still not ideal.
The problem is this process gets pretty cumbersome after some time due to having to export the huge level to max each time.
I'm currently trying to recreate this script's functionality inside sketchup. To simply select the objects you want to translate, and generate the text document for pasting in UE4.
Can anyone give me some pointers on where I can start? I can write a few simple things in ruby, but this kind of functionality is somewhat beyond my scope at the moment. A tutorial link and a few pointers from more experienced developers would go a long way.