Announcement

Collapse
No announcement yet.

Python - Get parent class

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Python - Get parent class

    Hi,

    How do I get the parent class from a list of blueprints?

    i.e Blueprint Actor Class, Character, Pawn Class. etc?

    I can't find the method that will return 'Actor', 'Character' , 'Pawn' as the class.

    I tried asset_class in AssetRegistryHelpers but that yields the same result of Blueprint.

    Appreciate any help!

    Code:
    # select blueprints in content folder
    # run script
    
    
    import unreal
    
    
    for sel in unreal.EditorUtilityLibrary().get_selected_assets():
    print sel.get_class()
    print sel.get_class().get_name()
    LogPython: <Object '/Script/Engine.Blueprint' (0x000001E63136B600) Class 'Class'>
    LogPython: Blueprint
    LogPython: <Object '/Script/Engine.Blueprint' (0x000001E63136B600) Class 'Class'>
    LogPython: Blueprint
    LogPython: <Object '/Script/Engine.Blueprint' (0x000001E63136B600) Class 'Class'>
    LogPython: Blueprint




    #2
    Code:
    for sel in unreal.EditorUtilityLibrary().get_selected_assets():
    print sel.get_class()
    print sel.get_class().get_name()
    
    path_gen = str(sel.get_path_name()) + '_C'
    bp_gc = unreal.load_object(None, path_gen)
    bcd = unreal.get_default_object(bp_gc)
    
    print bcd.get_class()
    print bcd.get_class().get_name()

    Comment


      #3
      Originally posted by mserena View Post
      Code:
      for sel in unreal.EditorUtilityLibrary().get_selected_assets():
      print sel.get_class()
      print sel.get_class().get_name()
      
      path_gen = str(sel.get_path_name()) + '_C'
      bp_gc = unreal.load_object(None, path_gen)
      bcd = unreal.get_default_object(bp_gc)
      
      print bcd.get_class()
      print bcd.get_class().get_name()


      Hey thanks for the reply but I'm still getting the same return value of just Class and Blueprint. Not Actor, Character or Pawn Class.

      I'm testing this on 25.1.




      Click image for larger version

Name:	unreal_pyclass.JPG
Views:	11
Size:	91.4 KB
ID:	1794263
      Attached Files

      Comment

      Working...
      X