Skip to content

Instantly share code, notes, and snippets.

@nafeesb
Last active August 11, 2019 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nafeesb/9482a55e98af3123f512c049533ead1d to your computer and use it in GitHub Desktop.
Save nafeesb/9482a55e98af3123f512c049533ead1d to your computer and use it in GitHub Desktop.
Unreal engine python snippets

Preamble

import unreal_engine as ue
from unreal_engine.classes import PoseableMeshComponent, SkeletalMesh, Skeleton, SkeletalMeshComponent
from unreal_engine import FTransform, FVector, FRotator, FQuat, FSoftSkinVertex

Access object from editor

actor = ue.editor_get_selected_actors()[0]
mesh = actor.get_component_by_type(SkeletalMeshComponent)

Object Info

# Name
obj.get_name()

Getting the skeleton

# Get the SkeletalMeshComponent
meshcomp = self.uobject.get_component_by_type(SkeletalMeshComponent)
print(meshcomp)
# <unreal_engine.UObject 'Mesh' (0x000001723054C100) UClass 'SkeletalMeshComponent' (refcnt: 5)>

# Get the SkeletalMesh
skelmesh = meshcomp.SkeletalMesh
print(skelmesh)
# <unreal_engine.UObject 'mica_rtdev_rig_v39' (0x000001721879B900) UClass 'SkeletalMesh' (refcnt: 6)>

# Get the Skeleton
skel = skelmesh.Skeleton
print(skel)
# <unreal_engine.UObject 'micah_rtmd_rig_v58_Skeleton' (0x000001720AD10F00) UClass 'Skeleton' (refcnt: 4)>
print(skel.skeleton_bones_get_num())
357

Direct class access

mesh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment