Ergebnis 1 bis 7 von 7

Phyton lernen..

  1. #1 Zitieren
    Veteran Avatar von DragonX
    Registriert seit
    May 2011
    Ort
    Gummibärchenland
    Beiträge
    605
    Hi

    Ich weis nicht ob es eine gute Idee ist aber ich versuche es einfach mal Da ich gerade Phyton lerne ( http://docs.python.org/3/tutorial/in...ds-programming )
    Bzw. jetzt anfange und das ganze auf English ist werde ich einfach immer kurz zusammenfassen und vll kann mir hier dann jemand sagen ob ich das richtig verstanden habe

    Also fangen wir an:


    "In the following examples, input and output are distinguished by the presence or absence of prompts (>>> and ...): to repeat the example, you must type everything after the prompt, when the prompt appears; lines that do not begin with a prompt are output from the interpreter. Note that a secondary prompt on a line by itself in an example means you must type a blank line; this is used to end a multi-line command.

    Many of the examples in this manual, even those entered at the interactive prompt, include comments. Comments in Python start with the hash character, #, and extend to the end of the physical line. A comment may appear at the start of a line or following whitespace or code, but not within a string literal. A hash character within a string literal is just a hash character. Since comments are to clarify code and are not interpreted by Python, they may be omitted when typing in examples.
    "


    Zsf.

    Ein Phyton Code beginnt immer mit >>> oder mit ... Wenn man einen kommentar hinzufügen will zum Script muss man # dafor setzten.

    Richtig verstanden?
    "To be a good professional engineer, always start to study late for exams. Because it teaches you how to manage time and tackle emergencies."
    -Bill Gates

    Need Gamekey? ---> http://www.kinguin.com.de/?acc=cegh8
    DragonX ist offline

  2. #2 Zitieren
    Ritter Avatar von Delta 38
    Registriert seit
    Nov 2008
    Ort
    Bremen
    Beiträge
    1.251
    Ja, aber nur in der Pythonkonsole
    Delta 38 ist offline

  3. #3 Zitieren
    Veteran Avatar von DragonX
    Registriert seit
    May 2011
    Ort
    Gummibärchenland
    Beiträge
    605
    Hä wie?
    "To be a good professional engineer, always start to study late for exams. Because it teaches you how to manage time and tackle emergencies."
    -Bill Gates

    Need Gamekey? ---> http://www.kinguin.com.de/?acc=cegh8
    DragonX ist offline

  4. #4 Zitieren
    Ritter Avatar von Delta 38
    Registriert seit
    Nov 2008
    Ort
    Bremen
    Beiträge
    1.251
    Also, du gibst das ja in er Pythonkonsole ein. Das ist sowas wie ein Life-Interpreter. Das bedeutet du gibst eine Zeile, bzw. einen Block Code ein und drückst Enter und dann wird das ganze ausgeführt. Ganze Programme sehen dann zum Beispiel so aus:

    (Ist ein Standart-Skript von Blender)
    Code:
    import bpy
    
    
    def main(context):
        obj = context.active_object
        mesh = obj.data
    
        is_editmode = (obj.mode == 'EDIT')
        if is_editmode:
            bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
    
        if not mesh.uv_textures:
            uvtex = bpy.ops.mesh.uv_texture_add()
        else:
            uvtex = mesh.uv_textures.active
    
        # adjust UVs
        for i, uv in enumerate(uvtex.data):
            uvs = uv.uv1, uv.uv2, uv.uv3, uv.uv4
            for j, v_idx in enumerate(mesh.faces[i].vertices):
                if uv.select_uv[j]:
                    # apply the location of the vertex as a UV
                    uvs[j][:] = mesh.vertices[v_idx].co.xy
    
        if is_editmode:
            bpy.ops.object.mode_set(mode='EDIT', toggle=False)
    
    
    class UvOperator(bpy.types.Operator):
        """UV Operator description"""
        bl_idname = "uv.simple_operator"
        bl_label = "Simple UV Operator"
    
        @classmethod
        def poll(cls, context):
            obj = context.active_object
            return (obj and obj.type == 'MESH')
    
        def execute(self, context):
            main(context)
            return {'FINISHED'}
    
    
    def register():
        bpy.utils.register_class(UvOperator)
    
    
    def unregister():
        bpy.utils.unregister_class(UvOperator)
    
    
    if __name__ == "__main__":
        register()
    
        # test call
        bpy.ops.uv.simple_operator()
    Gruß Delta
    Delta 38 ist offline

  5. #5 Zitieren
    Veteran Avatar von DragonX
    Registriert seit
    May 2011
    Ort
    Gummibärchenland
    Beiträge
    605
    Funktioniert dieser Code noch in Blender 2.56?
    http://www.pasteall.org/38556
    "To be a good professional engineer, always start to study late for exams. Because it teaches you how to manage time and tackle emergencies."
    -Bill Gates

    Need Gamekey? ---> http://www.kinguin.com.de/?acc=cegh8
    DragonX ist offline

  6. #6 Zitieren
    Ritter Avatar von Delta 38
    Registriert seit
    Nov 2008
    Ort
    Bremen
    Beiträge
    1.251
    Nein. Schon die Import-Zeile ist "veraltet", also import GameEngine und import Blender gibt es nicht mehr.
    Delta 38 ist offline

  7. #7 Zitieren
    Veteran Avatar von DragonX
    Registriert seit
    May 2011
    Ort
    Gummibärchenland
    Beiträge
    605
    Achso ok schade.. Was muss ich denn im Script ändern damit es funktioniert auser das ich ganz oben:

    import bge

    reinschreiben muss?
    "To be a good professional engineer, always start to study late for exams. Because it teaches you how to manage time and tackle emergencies."
    -Bill Gates

    Need Gamekey? ---> http://www.kinguin.com.de/?acc=cegh8
    DragonX ist offline

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •