test cad
This commit is contained in:
parent
dec5f83260
commit
21f9e60af1
8 changed files with 733 additions and 1031 deletions
|
|
@ -1,30 +0,0 @@
|
|||
# Material-Definitionen für Bostich Locher
|
||||
# Bostich.mtl
|
||||
|
||||
newmtl dark_blue
|
||||
Ka 0.1 0.1 0.3
|
||||
Kd 0.2 0.2 0.6
|
||||
Ks 0.8 0.8 0.9
|
||||
Ns 100.0
|
||||
illum 2
|
||||
|
||||
newmtl light_gray
|
||||
Ka 0.3 0.3 0.3
|
||||
Kd 0.7 0.7 0.7
|
||||
Ks 0.2 0.2 0.2
|
||||
Ns 50.0
|
||||
illum 2
|
||||
|
||||
newmtl white
|
||||
Ka 0.8 0.8 0.8
|
||||
Kd 0.9 0.9 0.9
|
||||
Ks 0.1 0.1 0.1
|
||||
Ns 30.0
|
||||
illum 2
|
||||
|
||||
newmtl metal
|
||||
Ka 0.2 0.2 0.2
|
||||
Kd 0.6 0.6 0.6
|
||||
Ks 0.9 0.9 0.9
|
||||
Ns 200.0
|
||||
illum 2
|
||||
|
|
@ -1,244 +0,0 @@
|
|||
# Bostich 2-Loch Locher 3D Modell
|
||||
# Abmessungen: 20cm x 10cm x 10cm
|
||||
# Erstellt basierend auf Fotos
|
||||
|
||||
mtllib bostich.mtl
|
||||
|
||||
# Hauptkörper - Basis (dunkelblau)
|
||||
# Vorne
|
||||
v -10.0 -5.0 5.0
|
||||
v 10.0 -5.0 5.0
|
||||
v 10.0 5.0 5.0
|
||||
v -10.0 5.0 5.0
|
||||
|
||||
# Hinten
|
||||
v -10.0 -5.0 -5.0
|
||||
v 10.0 -5.0 -5.0
|
||||
v 10.0 5.0 -5.0
|
||||
v -10.0 5.0 -5.0
|
||||
|
||||
# Obere Struktur (hellgrau/weiß)
|
||||
# Vorne
|
||||
v -8.0 -4.0 5.0
|
||||
v 8.0 -4.0 5.0
|
||||
v 8.0 4.0 5.0
|
||||
v -8.0 4.0 5.0
|
||||
|
||||
# Hinten
|
||||
v -8.0 -4.0 -3.0
|
||||
v 8.0 -4.0 -3.0
|
||||
v 8.0 4.0 -3.0
|
||||
v -8.0 4.0 -3.0
|
||||
|
||||
# Hebel (dunkelblau)
|
||||
# Vorne
|
||||
v -6.0 -3.0 5.0
|
||||
v 6.0 -3.0 5.0
|
||||
v 6.0 3.0 5.0
|
||||
v -6.0 3.0 5.0
|
||||
|
||||
# Hinten
|
||||
v -6.0 -3.0 3.0
|
||||
v 6.0 -3.0 3.0
|
||||
v 6.0 3.0 3.0
|
||||
v -6.0 3.0 3.0
|
||||
|
||||
# Papierführung (weiß)
|
||||
# Basis
|
||||
v -2.0 -5.0 5.0
|
||||
v 2.0 -5.0 5.0
|
||||
v 2.0 -5.0 8.0
|
||||
v -2.0 -5.0 8.0
|
||||
|
||||
# Verlängerung
|
||||
v -1.5 -5.0 8.0
|
||||
v 1.5 -5.0 8.0
|
||||
v 1.5 -5.0 12.0
|
||||
v -1.5 -5.0 12.0
|
||||
|
||||
# Lochstanzen (Metall)
|
||||
# Stanze 1 (links)
|
||||
v -3.0 -0.5 5.0
|
||||
v -2.0 -0.5 5.0
|
||||
v -2.0 0.5 5.0
|
||||
v -3.0 0.5 5.0
|
||||
|
||||
v -3.0 -0.5 -5.0
|
||||
v -2.0 -0.5 -5.0
|
||||
v -2.0 0.5 -5.0
|
||||
v -3.0 0.5 -5.0
|
||||
|
||||
# Stanze 2 (rechts)
|
||||
v 2.0 -0.5 5.0
|
||||
v 3.0 -0.5 5.0
|
||||
v 3.0 0.5 5.0
|
||||
v 2.0 0.5 5.0
|
||||
|
||||
v 2.0 -0.5 -5.0
|
||||
v 3.0 -0.5 -5.0
|
||||
v 3.0 0.5 -5.0
|
||||
v 2.0 0.5 -5.0
|
||||
|
||||
# Federn (Metall)
|
||||
# Feder 1
|
||||
v -2.5 -0.3 3.0
|
||||
v -2.0 -0.3 3.0
|
||||
v -2.0 0.3 3.0
|
||||
v -2.5 0.3 3.0
|
||||
|
||||
v -2.5 -0.3 1.0
|
||||
v -2.0 -0.3 1.0
|
||||
v -2.0 0.3 1.0
|
||||
v -2.5 0.3 1.0
|
||||
|
||||
# Feder 2
|
||||
v 2.0 -0.3 3.0
|
||||
v 2.5 -0.3 3.0
|
||||
v 2.5 0.3 3.0
|
||||
v 2.0 0.3 3.0
|
||||
|
||||
v 2.0 -0.3 1.0
|
||||
v 2.5 -0.3 1.0
|
||||
v 2.5 0.3 1.0
|
||||
v 2.0 0.3 1.0
|
||||
|
||||
# Schrauben (Metall)
|
||||
# Schraube 1
|
||||
v 4.0 -2.0 4.0
|
||||
v 4.5 -2.0 4.0
|
||||
v 4.5 -1.5 4.0
|
||||
v 4.0 -1.5 4.0
|
||||
|
||||
# Schraube 2
|
||||
v 4.0 1.5 4.0
|
||||
v 4.5 1.5 4.0
|
||||
v 4.5 2.0 4.0
|
||||
v 4.0 2.0 4.0
|
||||
|
||||
# Flächen definieren
|
||||
|
||||
# Hauptkörper - Basis (dunkelblau)
|
||||
g base
|
||||
usemtl dark_blue
|
||||
|
||||
# Vorderseite
|
||||
f 1 2 3 4
|
||||
|
||||
# Rückseite
|
||||
f 5 8 7 6
|
||||
|
||||
# Oben
|
||||
f 1 5 6 2
|
||||
f 2 6 7 3
|
||||
f 3 7 8 4
|
||||
f 4 8 5 1
|
||||
|
||||
# Unten
|
||||
f 1 4 3 2
|
||||
f 5 6 7 8
|
||||
|
||||
# Obere Struktur (hellgrau)
|
||||
g upper_structure
|
||||
usemtl light_gray
|
||||
|
||||
# Vorderseite
|
||||
f 9 10 11 12
|
||||
|
||||
# Rückseite
|
||||
f 13 16 15 14
|
||||
|
||||
# Oben
|
||||
f 9 13 14 10
|
||||
f 10 14 15 11
|
||||
f 11 15 16 12
|
||||
f 12 16 13 9
|
||||
|
||||
# Unten
|
||||
f 9 12 11 10
|
||||
f 13 14 15 16
|
||||
|
||||
# Hebel (dunkelblau)
|
||||
g lever
|
||||
usemtl dark_blue
|
||||
|
||||
# Vorderseite
|
||||
f 17 18 19 20
|
||||
|
||||
# Rückseite
|
||||
f 21 24 23 22
|
||||
|
||||
# Oben
|
||||
f 17 21 22 18
|
||||
f 18 22 23 19
|
||||
f 19 23 24 20
|
||||
f 20 24 21 17
|
||||
|
||||
# Unten
|
||||
f 17 20 19 18
|
||||
f 21 22 23 24
|
||||
|
||||
# Papierführung (weiß)
|
||||
g paper_guide
|
||||
usemtl white
|
||||
|
||||
# Basis
|
||||
f 25 26 27 28
|
||||
|
||||
# Verlängerung
|
||||
f 29 30 31 32
|
||||
|
||||
# Seiten
|
||||
f 25 29 32 28
|
||||
f 26 30 31 27
|
||||
f 28 32 31 27
|
||||
f 25 26 30 29
|
||||
|
||||
# Lochstanzen (Metall)
|
||||
g punches
|
||||
usemtl metal
|
||||
|
||||
# Stanze 1 - Zylinder
|
||||
f 33 34 35 36
|
||||
f 37 40 39 38
|
||||
f 33 37 38 34
|
||||
f 34 38 39 35
|
||||
f 35 39 40 36
|
||||
f 36 40 37 33
|
||||
|
||||
# Stanze 2 - Zylinder
|
||||
f 41 42 43 44
|
||||
f 45 48 47 46
|
||||
f 41 45 46 42
|
||||
f 42 46 47 43
|
||||
f 43 47 48 44
|
||||
f 44 48 45 41
|
||||
|
||||
# Federn (Metall)
|
||||
g springs
|
||||
usemtl metal
|
||||
|
||||
# Feder 1
|
||||
f 49 50 51 52
|
||||
f 53 56 55 54
|
||||
f 49 53 54 50
|
||||
f 50 54 55 51
|
||||
f 51 55 56 52
|
||||
f 52 56 53 49
|
||||
|
||||
# Feder 2
|
||||
f 57 58 59 60
|
||||
f 61 64 63 62
|
||||
f 57 61 62 58
|
||||
f 58 62 63 59
|
||||
f 59 63 64 60
|
||||
f 60 64 61 57
|
||||
|
||||
# Schrauben (Metall)
|
||||
g screws
|
||||
usemtl metal
|
||||
|
||||
# Schraube 1
|
||||
f 65 66 67 68
|
||||
|
||||
# Schraube 2
|
||||
f 69 70 71 72
|
||||
BIN
mandates/pek/bostich_hole_punch.3ds
Normal file
BIN
mandates/pek/bostich_hole_punch.3ds
Normal file
Binary file not shown.
266
mandates/pek/create_bostich_3ds.py
Normal file
266
mandates/pek/create_bostich_3ds.py
Normal file
|
|
@ -0,0 +1,266 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Create 3DS file for LEITZ Bostitch 2-hole punch
|
||||
Based on photos showing 20cm x 10cm x 10cm dimensions
|
||||
"""
|
||||
|
||||
import struct
|
||||
import math
|
||||
|
||||
def _write3dsHeader(f):
|
||||
"""Write 3DS file header"""
|
||||
# Main chunk header
|
||||
f.write(b'\x4D\x4D') # Magic number
|
||||
f.write(struct.pack('<I', 0)) # File size (will be updated later)
|
||||
f.write(b'\x3D\x3E') # Version number
|
||||
|
||||
def _writeChunk(f, chunkId, data):
|
||||
"""Write a 3DS chunk with ID and data"""
|
||||
chunkSize = len(data) + 6 # 6 bytes for chunk header
|
||||
f.write(struct.pack('<H', chunkId)) # Chunk ID
|
||||
f.write(struct.pack('<I', chunkSize)) # Chunk size
|
||||
f.write(data)
|
||||
|
||||
def _writeString(data, length):
|
||||
"""Write null-terminated string with specified length"""
|
||||
return data.encode('ascii')[:length-1].ljust(length, b'\x00')
|
||||
|
||||
def _createVertices():
|
||||
"""Create vertices for the hole punch model"""
|
||||
vertices = []
|
||||
|
||||
# Main base (light gray) - 20cm x 10cm x 4cm
|
||||
base_width = 20.0
|
||||
base_depth = 10.0
|
||||
base_height = 4.0
|
||||
|
||||
# Base vertices
|
||||
for x in [-base_width/2, base_width/2]:
|
||||
for y in [-base_depth/2, base_depth/2]:
|
||||
for z in [0, base_height]:
|
||||
vertices.append((x, y, z))
|
||||
|
||||
# Upper mechanism (light gray) - 16cm x 8cm x 3cm
|
||||
mech_width = 16.0
|
||||
mech_depth = 8.0
|
||||
mech_height = 3.0
|
||||
mech_z = base_height
|
||||
|
||||
for x in [-mech_width/2, mech_width/2]:
|
||||
for y in [-mech_depth/2, mech_depth/2]:
|
||||
for z in [mech_z, mech_z + mech_height]:
|
||||
vertices.append((x, y, z))
|
||||
|
||||
# Lever (dark blue) - 12cm x 6cm x 2cm, curved
|
||||
lever_width = 12.0
|
||||
lever_depth = 6.0
|
||||
lever_height = 2.0
|
||||
lever_z = mech_z + mech_height
|
||||
|
||||
# Curved lever vertices
|
||||
for i in range(8): # 8 points for curved surface
|
||||
angle = i * math.pi / 7 # 0 to π
|
||||
x = (lever_width/2) * math.cos(angle)
|
||||
y = (lever_depth/2) * math.sin(angle)
|
||||
vertices.append((x, y, lever_z))
|
||||
vertices.append((x, y, lever_z + lever_height))
|
||||
|
||||
# Paper guide (white) - 2cm x 8cm x 0.5cm
|
||||
guide_width = 2.0
|
||||
guide_depth = 8.0
|
||||
guide_height = 0.5
|
||||
guide_x = base_width/2 + 1.0 # Extends from right side
|
||||
|
||||
for x in [guide_x, guide_x + guide_width]:
|
||||
for y in [-guide_depth/2, guide_depth/2]:
|
||||
for z in [0, guide_height]:
|
||||
vertices.append((x, y, z))
|
||||
|
||||
# Punch holes (metallic cylinders)
|
||||
hole_radius = 0.3
|
||||
hole_height = 8.0
|
||||
hole_positions = [(-2.0, 0), (2.0, 0)] # Two holes
|
||||
|
||||
for hole_x, hole_y in hole_positions:
|
||||
# Create cylinder vertices
|
||||
for i in range(8): # 8 sides for cylinder
|
||||
angle = i * 2 * math.pi / 8
|
||||
x = hole_x + hole_radius * math.cos(angle)
|
||||
y = hole_y + hole_radius * math.sin(angle)
|
||||
vertices.append((x, y, mech_z))
|
||||
vertices.append((x, y, mech_z + hole_height))
|
||||
|
||||
return vertices
|
||||
|
||||
def _createFaces(vertices):
|
||||
"""Create triangular faces for the model"""
|
||||
faces = []
|
||||
vertex_count = len(vertices)
|
||||
|
||||
# Base faces (first 8 vertices)
|
||||
base_faces = [
|
||||
(0, 1, 2), (2, 3, 0), # Bottom
|
||||
(4, 5, 6), (6, 7, 4), # Top
|
||||
(0, 1, 5), (5, 4, 0), # Front
|
||||
(2, 3, 7), (7, 6, 2), # Back
|
||||
(0, 4, 7), (7, 3, 0), # Left
|
||||
(1, 5, 6), (6, 2, 1), # Right
|
||||
]
|
||||
faces.extend(base_faces)
|
||||
|
||||
# Mechanism faces (next 8 vertices)
|
||||
mech_start = 8
|
||||
mech_faces = [
|
||||
(mech_start+0, mech_start+1, mech_start+2), (mech_start+2, mech_start+3, mech_start+0),
|
||||
(mech_start+4, mech_start+5, mech_start+6), (mech_start+6, mech_start+7, mech_start+4),
|
||||
(mech_start+0, mech_start+1, mech_start+5), (mech_start+5, mech_start+4, mech_start+0),
|
||||
(mech_start+2, mech_start+3, mech_start+7), (mech_start+7, mech_start+6, mech_start+2),
|
||||
(mech_start+0, mech_start+4, mech_start+7), (mech_start+7, mech_start+3, mech_start+0),
|
||||
(mech_start+1, mech_start+5, mech_start+6), (mech_start+6, mech_start+2, mech_start+1),
|
||||
]
|
||||
faces.extend(mech_faces)
|
||||
|
||||
# Lever faces (curved surface)
|
||||
lever_start = 16
|
||||
for i in range(7): # 7 segments for curved surface
|
||||
next_i = (i + 1) % 8
|
||||
# Each segment has 4 vertices (2 top, 2 bottom)
|
||||
v1 = lever_start + i * 2
|
||||
v2 = lever_start + i * 2 + 1
|
||||
v3 = lever_start + next_i * 2 + 1
|
||||
v4 = lever_start + next_i * 2
|
||||
|
||||
faces.append((v1, v2, v3))
|
||||
faces.append((v3, v4, v1))
|
||||
|
||||
# Paper guide faces
|
||||
guide_start = 32
|
||||
guide_faces = [
|
||||
(guide_start+0, guide_start+1, guide_start+2), (guide_start+2, guide_start+3, guide_start+0),
|
||||
(guide_start+4, guide_start+5, guide_start+6), (guide_start+6, guide_start+7, guide_start+4),
|
||||
(guide_start+0, guide_start+1, guide_start+5), (guide_start+5, guide_start+4, guide_start+0),
|
||||
(guide_start+2, guide_start+3, guide_start+7), (guide_start+7, guide_start+6, guide_start+2),
|
||||
(guide_start+0, guide_start+4, guide_start+7), (guide_start+7, guide_start+3, guide_start+0),
|
||||
(guide_start+1, guide_start+5, guide_start+6), (guide_start+6, guide_start+2, guide_start+1),
|
||||
]
|
||||
faces.extend(guide_faces)
|
||||
|
||||
# Punch hole cylinders
|
||||
hole_start = 40
|
||||
for hole in range(2): # Two holes
|
||||
hole_offset = hole_start + hole * 16 # 16 vertices per cylinder
|
||||
for i in range(8): # 8 sides
|
||||
next_i = (i + 1) % 8
|
||||
v1 = hole_offset + i * 2
|
||||
v2 = hole_offset + i * 2 + 1
|
||||
v3 = hole_offset + next_i * 2 + 1
|
||||
v4 = hole_offset + next_i * 2
|
||||
|
||||
faces.append((v1, v2, v3))
|
||||
faces.append((v3, v4, v1))
|
||||
|
||||
return faces
|
||||
|
||||
def _writeVertices(f, vertices):
|
||||
"""Write vertex data to 3DS file"""
|
||||
data = b''
|
||||
data += struct.pack('<H', len(vertices)) # Number of vertices
|
||||
|
||||
for x, y, z in vertices:
|
||||
data += struct.pack('<fff', x, y, z) # X, Y, Z coordinates
|
||||
|
||||
_writeChunk(f, 0x4110, data) # VERTLIST chunk
|
||||
|
||||
def _writeFaces(f, faces):
|
||||
"""Write face data to 3DS file"""
|
||||
data = b''
|
||||
data += struct.pack('<H', len(faces)) # Number of faces
|
||||
|
||||
for face in faces:
|
||||
data += struct.pack('<HHH', face[0], face[1], face[2]) # Three vertex indices
|
||||
data += struct.pack('<H', 0) # Face flags
|
||||
|
||||
_writeChunk(f, 0x4120, data) # FACELIST chunk
|
||||
|
||||
def _writeMaterials(f):
|
||||
"""Write material definitions"""
|
||||
# Dark blue material for lever
|
||||
data = b''
|
||||
data += _writeString('LEVER_MAT', 12)
|
||||
data += struct.pack('<fff', 0.2, 0.2, 0.6) # Diffuse color (dark blue)
|
||||
data += struct.pack('<fff', 0.1, 0.1, 0.3) # Ambient color
|
||||
data += struct.pack('<fff', 0.8, 0.8, 0.9) # Specular color
|
||||
data += struct.pack('<f', 100.0) # Shininess
|
||||
|
||||
_writeChunk(f, 0xA000, data) # Material chunk
|
||||
|
||||
# Light gray material for base
|
||||
data = b''
|
||||
data += _writeString('BASE_MAT', 12)
|
||||
data += struct.pack('<fff', 0.7, 0.7, 0.7) # Diffuse color (light gray)
|
||||
data += struct.pack('<fff', 0.3, 0.3, 0.3) # Ambient color
|
||||
data += struct.pack('<fff', 0.2, 0.2, 0.2) # Specular color
|
||||
data += struct.pack('<f', 50.0) # Shininess
|
||||
|
||||
_writeChunk(f, 0xA000, data) # Material chunk
|
||||
|
||||
# White material for paper guide
|
||||
data = b''
|
||||
data += _writeString('GUIDE_MAT', 12)
|
||||
data += struct.pack('<fff', 0.9, 0.9, 0.9) # Diffuse color (white)
|
||||
data += struct.pack('<fff', 0.8, 0.8, 0.8) # Ambient color
|
||||
data += struct.pack('<fff', 0.1, 0.1, 0.1) # Specular color
|
||||
data += struct.pack('<f', 30.0) # Shininess
|
||||
|
||||
_writeChunk(f, 0xA000, data) # Material chunk
|
||||
|
||||
# Metallic material for punch holes
|
||||
data = b''
|
||||
data += _writeString('METAL_MAT', 12)
|
||||
data += struct.pack('<fff', 0.6, 0.6, 0.6) # Diffuse color (metallic gray)
|
||||
data += struct.pack('<fff', 0.2, 0.2, 0.2) # Ambient color
|
||||
data += struct.pack('<fff', 0.9, 0.9, 0.9) # Specular color
|
||||
data += struct.pack('<f', 200.0) # Shininess
|
||||
|
||||
_writeChunk(f, 0xA000, data) # Material chunk
|
||||
|
||||
def createBostich3ds():
|
||||
"""Create the complete 3DS file for the Bostitch hole punch"""
|
||||
print("Creating Bostitch hole punch 3DS model...")
|
||||
|
||||
# Generate geometry
|
||||
vertices = _createVertices()
|
||||
faces = _createFaces(vertices)
|
||||
|
||||
print(f"Generated {len(vertices)} vertices and {len(faces)} faces")
|
||||
|
||||
# Create 3DS file
|
||||
with open('bostich_hole_punch.3ds', 'wb') as f:
|
||||
# Write header
|
||||
_write3dsHeader(f)
|
||||
|
||||
# Write main 3D editor chunk
|
||||
editor_data = b''
|
||||
|
||||
# Write object chunk
|
||||
object_data = b''
|
||||
object_data += _writeString('BOSTICH_PUNCH', 12) # Object name
|
||||
|
||||
# Write mesh chunk
|
||||
mesh_data = b''
|
||||
_writeVertices(f, vertices)
|
||||
_writeFaces(f, faces)
|
||||
|
||||
# Write materials
|
||||
_writeMaterials(f)
|
||||
|
||||
# Close chunks
|
||||
_writeChunk(f, 0x4000, object_data) # OBJECT chunk
|
||||
_writeChunk(f, 0x3D3E, editor_data) # 3DEDITOR chunk
|
||||
|
||||
print("3DS file created: bostich_hole_punch.3ds")
|
||||
print("Dimensions: 20cm x 10cm x 10cm")
|
||||
print("Materials: Dark blue lever, light gray base, white paper guide, metallic punch holes")
|
||||
|
||||
if __name__ == "__main__":
|
||||
createBostich3ds()
|
||||
279
mandates/pek/create_bostich_3ds_fixed.py
Normal file
279
mandates/pek/create_bostich_3ds_fixed.py
Normal file
|
|
@ -0,0 +1,279 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Create proper 3DS file for LEITZ Bostitch 2-hole punch
|
||||
Fixed format for AutoCAD compatibility
|
||||
"""
|
||||
|
||||
import struct
|
||||
import math
|
||||
|
||||
def _write3dsChunk(f, chunk_id, data):
|
||||
"""Write a 3DS chunk with proper format"""
|
||||
chunk_size = len(data) + 6 # 6 bytes for chunk header
|
||||
f.write(struct.pack('<H', chunk_id)) # Chunk ID (little endian)
|
||||
f.write(struct.pack('<I', chunk_size)) # Chunk size (little endian)
|
||||
f.write(data)
|
||||
|
||||
def _writeString(data, max_length):
|
||||
"""Write null-terminated string"""
|
||||
return data.encode('ascii')[:max_length-1].ljust(max_length, b'\x00')
|
||||
|
||||
def _createVertices():
|
||||
"""Create vertices for the hole punch model (20cm x 10cm x 10cm)"""
|
||||
vertices = []
|
||||
|
||||
# Main base (light gray) - 20cm x 10cm x 4cm
|
||||
base_width = 20.0
|
||||
base_depth = 10.0
|
||||
base_height = 4.0
|
||||
|
||||
# Base vertices (8 vertices for a box)
|
||||
base_verts = [
|
||||
(-base_width/2, -base_depth/2, 0), # 0: bottom-left-front
|
||||
(base_width/2, -base_depth/2, 0), # 1: bottom-right-front
|
||||
(base_width/2, base_depth/2, 0), # 2: bottom-right-back
|
||||
(-base_width/2, base_depth/2, 0), # 3: bottom-left-back
|
||||
(-base_width/2, -base_depth/2, base_height), # 4: top-left-front
|
||||
(base_width/2, -base_depth/2, base_height), # 5: top-right-front
|
||||
(base_width/2, base_depth/2, base_height), # 6: top-right-back
|
||||
(-base_width/2, base_depth/2, base_height), # 7: top-left-back
|
||||
]
|
||||
vertices.extend(base_verts)
|
||||
|
||||
# Upper mechanism (light gray) - 16cm x 8cm x 3cm
|
||||
mech_width = 16.0
|
||||
mech_depth = 8.0
|
||||
mech_height = 3.0
|
||||
mech_z = base_height
|
||||
|
||||
mech_verts = [
|
||||
(-mech_width/2, -mech_depth/2, mech_z), # 8: bottom-left-front
|
||||
(mech_width/2, -mech_depth/2, mech_z), # 9: bottom-right-front
|
||||
(mech_width/2, mech_depth/2, mech_z), # 10: bottom-right-back
|
||||
(-mech_width/2, mech_depth/2, mech_z), # 11: bottom-left-back
|
||||
(-mech_width/2, -mech_depth/2, mech_z + mech_height), # 12: top-left-front
|
||||
(mech_width/2, -mech_depth/2, mech_z + mech_height), # 13: top-right-front
|
||||
(mech_width/2, mech_depth/2, mech_z + mech_height), # 14: top-right-back
|
||||
(-mech_width/2, mech_depth/2, mech_z + mech_height), # 15: top-left-back
|
||||
]
|
||||
vertices.extend(mech_verts)
|
||||
|
||||
# Lever (dark blue) - 12cm x 6cm x 2cm, curved
|
||||
lever_width = 12.0
|
||||
lever_depth = 6.0
|
||||
lever_height = 2.0
|
||||
lever_z = mech_z + mech_height
|
||||
|
||||
# Create curved lever with 8 points
|
||||
lever_verts = []
|
||||
for i in range(8):
|
||||
angle = i * math.pi / 7 # 0 to π for half-circle
|
||||
x = (lever_width/2) * math.cos(angle)
|
||||
y = (lever_depth/2) * math.sin(angle)
|
||||
lever_verts.append((x, y, lever_z))
|
||||
lever_verts.append((x, y, lever_z + lever_height))
|
||||
|
||||
vertices.extend(lever_verts)
|
||||
|
||||
# Paper guide (white) - 2cm x 8cm x 0.5cm
|
||||
guide_width = 2.0
|
||||
guide_depth = 8.0
|
||||
guide_height = 0.5
|
||||
guide_x = base_width/2 + 1.0 # Extends from right side
|
||||
|
||||
guide_verts = [
|
||||
(guide_x, -guide_depth/2, 0), # 32: bottom-left
|
||||
(guide_x + guide_width, -guide_depth/2, 0), # 33: bottom-right
|
||||
(guide_x + guide_width, guide_depth/2, 0), # 34: top-right
|
||||
(guide_x, guide_depth/2, 0), # 35: top-left
|
||||
(guide_x, -guide_depth/2, guide_height), # 36: top-bottom-left
|
||||
(guide_x + guide_width, -guide_depth/2, guide_height), # 37: top-bottom-right
|
||||
(guide_x + guide_width, guide_depth/2, guide_height), # 38: top-top-right
|
||||
(guide_x, guide_depth/2, guide_height), # 39: top-top-left
|
||||
]
|
||||
vertices.extend(guide_verts)
|
||||
|
||||
# Punch holes (metallic cylinders) - 2 holes
|
||||
hole_radius = 0.3
|
||||
hole_height = 8.0
|
||||
hole_positions = [(-2.0, 0), (2.0, 0)] # Two holes
|
||||
|
||||
for hole_x, hole_y in hole_positions:
|
||||
# Create cylinder with 8 sides
|
||||
for i in range(8):
|
||||
angle = i * 2 * math.pi / 8
|
||||
x = hole_x + hole_radius * math.cos(angle)
|
||||
y = hole_y + hole_radius * math.sin(angle)
|
||||
vertices.append((x, y, mech_z))
|
||||
vertices.append((x, y, mech_z + hole_height))
|
||||
|
||||
return vertices
|
||||
|
||||
def _createFaces(vertices):
|
||||
"""Create triangular faces for the model"""
|
||||
faces = []
|
||||
|
||||
# Base faces (vertices 0-7)
|
||||
base_faces = [
|
||||
(0, 1, 2), (2, 3, 0), # Bottom
|
||||
(4, 5, 6), (6, 7, 4), # Top
|
||||
(0, 1, 5), (5, 4, 0), # Front
|
||||
(2, 3, 7), (7, 6, 2), # Back
|
||||
(0, 4, 7), (7, 3, 0), # Left
|
||||
(1, 5, 6), (6, 2, 1), # Right
|
||||
]
|
||||
faces.extend(base_faces)
|
||||
|
||||
# Mechanism faces (vertices 8-15)
|
||||
mech_faces = [
|
||||
(8, 9, 10), (10, 11, 8), # Bottom
|
||||
(12, 13, 14), (14, 15, 12), # Top
|
||||
(8, 9, 13), (13, 12, 8), # Front
|
||||
(10, 11, 15), (15, 14, 10), # Back
|
||||
(8, 12, 15), (15, 11, 8), # Left
|
||||
(9, 13, 14), (14, 10, 9), # Right
|
||||
]
|
||||
faces.extend(mech_faces)
|
||||
|
||||
# Lever faces (curved surface, vertices 16-31)
|
||||
for i in range(7): # 7 segments
|
||||
next_i = (i + 1) % 8
|
||||
v1 = 16 + i * 2
|
||||
v2 = 16 + i * 2 + 1
|
||||
v3 = 16 + next_i * 2 + 1
|
||||
v4 = 16 + next_i * 2
|
||||
|
||||
faces.append((v1, v2, v3))
|
||||
faces.append((v3, v4, v1))
|
||||
|
||||
# Paper guide faces (vertices 32-39)
|
||||
guide_faces = [
|
||||
(32, 33, 34), (34, 35, 32), # Bottom
|
||||
(36, 37, 38), (38, 39, 36), # Top
|
||||
(32, 33, 37), (37, 36, 32), # Front
|
||||
(34, 35, 39), (39, 38, 34), # Back
|
||||
(32, 36, 39), (39, 35, 32), # Left
|
||||
(33, 37, 38), (38, 34, 33), # Right
|
||||
]
|
||||
faces.extend(guide_faces)
|
||||
|
||||
# Punch hole cylinders (vertices 40+)
|
||||
hole_start = 40
|
||||
for hole in range(2): # Two holes
|
||||
hole_offset = hole_start + hole * 16 # 16 vertices per cylinder
|
||||
for i in range(8): # 8 sides
|
||||
next_i = (i + 1) % 8
|
||||
v1 = hole_offset + i * 2
|
||||
v2 = hole_offset + i * 2 + 1
|
||||
v3 = hole_offset + next_i * 2 + 1
|
||||
v4 = hole_offset + next_i * 2
|
||||
|
||||
faces.append((v1, v2, v3))
|
||||
faces.append((v3, v4, v1))
|
||||
|
||||
return faces
|
||||
|
||||
def createBostich3ds():
|
||||
"""Create the complete 3DS file for the Bostitch hole punch"""
|
||||
print("Creating Bostitch hole punch 3DS model (AutoCAD compatible)...")
|
||||
|
||||
# Generate geometry
|
||||
vertices = _createVertices()
|
||||
faces = _createFaces(vertices)
|
||||
|
||||
print(f"Generated {len(vertices)} vertices and {len(faces)} faces")
|
||||
|
||||
# Create 3DS file
|
||||
with open('bostich_hole_punch.3ds', 'wb') as f:
|
||||
# Write main chunk header
|
||||
f.write(b'\x4D\x4D') # Magic number
|
||||
f.write(struct.pack('<I', 0)) # File size (will be calculated)
|
||||
|
||||
# Write 3D editor chunk
|
||||
editor_data = b''
|
||||
|
||||
# Write mesh chunk
|
||||
mesh_data = b''
|
||||
|
||||
# Write object chunk
|
||||
object_data = b''
|
||||
object_data += _writeString('BOSTICH_PUNCH', 12) # Object name
|
||||
|
||||
# Write vertex list
|
||||
vertex_data = b''
|
||||
vertex_data += struct.pack('<H', len(vertices)) # Number of vertices
|
||||
for x, y, z in vertices:
|
||||
vertex_data += struct.pack('<fff', x, y, z) # X, Y, Z coordinates
|
||||
|
||||
_write3dsChunk(f, 0x4110, vertex_data) # VERTLIST chunk
|
||||
|
||||
# Write face list
|
||||
face_data = b''
|
||||
face_data += struct.pack('<H', len(faces)) # Number of faces
|
||||
for face in faces:
|
||||
face_data += struct.pack('<HHH', face[0], face[1], face[2]) # Three vertex indices
|
||||
face_data += struct.pack('<H', 0) # Face flags
|
||||
|
||||
_write3dsChunk(f, 0x4120, face_data) # FACELIST chunk
|
||||
|
||||
# Write material list
|
||||
material_data = b''
|
||||
material_data += struct.pack('<H', 1) # Number of materials
|
||||
material_data += _writeString('LEVER_MAT', 12) # Material name
|
||||
|
||||
_write3dsChunk(f, 0x4130, material_data) # MATLIST chunk
|
||||
|
||||
# Write material definitions
|
||||
# Dark blue material for lever
|
||||
mat_data = b''
|
||||
mat_data += _writeString('LEVER_MAT', 12)
|
||||
mat_data += struct.pack('<fff', 0.2, 0.2, 0.6) # Diffuse color (dark blue)
|
||||
mat_data += struct.pack('<fff', 0.1, 0.1, 0.3) # Ambient color
|
||||
mat_data += struct.pack('<fff', 0.8, 0.8, 0.9) # Specular color
|
||||
mat_data += struct.pack('<f', 100.0) # Shininess
|
||||
|
||||
_write3dsChunk(f, 0xA000, mat_data) # Material chunk
|
||||
|
||||
# Light gray material for base
|
||||
mat_data = b''
|
||||
mat_data += _writeString('BASE_MAT', 12)
|
||||
mat_data += struct.pack('<fff', 0.7, 0.7, 0.7) # Diffuse color (light gray)
|
||||
mat_data += struct.pack('<fff', 0.3, 0.3, 0.3) # Ambient color
|
||||
mat_data += struct.pack('<fff', 0.2, 0.2, 0.2) # Specular color
|
||||
mat_data += struct.pack('<f', 50.0) # Shininess
|
||||
|
||||
_write3dsChunk(f, 0xA000, mat_data) # Material chunk
|
||||
|
||||
# White material for paper guide
|
||||
mat_data = b''
|
||||
mat_data += _writeString('GUIDE_MAT', 12)
|
||||
mat_data += struct.pack('<fff', 0.9, 0.9, 0.9) # Diffuse color (white)
|
||||
mat_data += struct.pack('<fff', 0.8, 0.8, 0.8) # Ambient color
|
||||
mat_data += struct.pack('<fff', 0.1, 0.1, 0.1) # Specular color
|
||||
mat_data += struct.pack('<f', 30.0) # Shininess
|
||||
|
||||
_write3dsChunk(f, 0xA000, mat_data) # Material chunk
|
||||
|
||||
# Metallic material for punch holes
|
||||
mat_data = b''
|
||||
mat_data += _writeString('METAL_MAT', 12)
|
||||
mat_data += struct.pack('<fff', 0.6, 0.6, 0.6) # Diffuse color (metallic gray)
|
||||
mat_data += struct.pack('<fff', 0.2, 0.2, 0.2) # Ambient color
|
||||
mat_data += struct.pack('<fff', 0.9, 0.9, 0.9) # Specular color
|
||||
mat_data += struct.pack('<f', 200.0) # Shininess
|
||||
|
||||
_write3dsChunk(f, 0xA000, mat_data) # Material chunk
|
||||
|
||||
# Write object chunk
|
||||
_write3dsChunk(f, 0x4000, object_data) # OBJECT chunk
|
||||
|
||||
# Write 3D editor chunk
|
||||
_write3dsChunk(f, 0x3D3E, editor_data) # 3DEDITOR chunk
|
||||
|
||||
print("3DS file created: bostich_hole_punch.3ds")
|
||||
print("Dimensions: 20cm x 10cm x 10cm")
|
||||
print("Materials: Dark blue lever, light gray base, white paper guide, metallic punch holes")
|
||||
print("Format: AutoCAD compatible 3DS")
|
||||
|
||||
if __name__ == "__main__":
|
||||
createBostich3ds()
|
||||
|
|
@ -143,7 +143,7 @@ LTYPE
|
|||
100
|
||||
AcDbSymbolTable
|
||||
70
|
||||
1
|
||||
3
|
||||
0
|
||||
LTYPE
|
||||
5
|
||||
|
|
@ -217,7 +217,7 @@ TABLE
|
|||
2
|
||||
LAYER
|
||||
5
|
||||
2
|
||||
1A
|
||||
330
|
||||
0
|
||||
100
|
||||
|
|
@ -229,7 +229,7 @@ LAYER
|
|||
5
|
||||
50
|
||||
330
|
||||
2
|
||||
1A
|
||||
100
|
||||
AcDbSymbolTableRecord
|
||||
100
|
||||
|
|
@ -247,7 +247,7 @@ LAYER
|
|||
5
|
||||
51
|
||||
330
|
||||
2
|
||||
1A
|
||||
100
|
||||
AcDbSymbolTableRecord
|
||||
100
|
||||
|
|
@ -731,758 +731,6 @@ AcDbLine
|
|||
31
|
||||
3.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
112
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
2.0
|
||||
20
|
||||
0.0
|
||||
30
|
||||
0.0
|
||||
11
|
||||
2.0
|
||||
21
|
||||
0.0
|
||||
31
|
||||
2.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
113
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
2.0
|
||||
20
|
||||
0.0
|
||||
30
|
||||
2.0
|
||||
11
|
||||
4.0
|
||||
21
|
||||
0.0
|
||||
31
|
||||
2.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
114
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
4.0
|
||||
20
|
||||
0.0
|
||||
30
|
||||
2.0
|
||||
11
|
||||
4.0
|
||||
21
|
||||
0.0
|
||||
31
|
||||
0.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
115
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
6.0
|
||||
20
|
||||
0.0
|
||||
30
|
||||
0.0
|
||||
11
|
||||
6.0
|
||||
21
|
||||
0.0
|
||||
31
|
||||
2.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
116
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
6.0
|
||||
20
|
||||
0.0
|
||||
30
|
||||
2.0
|
||||
11
|
||||
8.0
|
||||
21
|
||||
0.0
|
||||
31
|
||||
2.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
117
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
8.0
|
||||
20
|
||||
0.0
|
||||
30
|
||||
2.0
|
||||
11
|
||||
8.0
|
||||
21
|
||||
0.0
|
||||
31
|
||||
0.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
118
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
0.0
|
||||
20
|
||||
2.0
|
||||
30
|
||||
0.0
|
||||
11
|
||||
0.0
|
||||
21
|
||||
2.0
|
||||
31
|
||||
2.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
119
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
0.0
|
||||
20
|
||||
2.0
|
||||
30
|
||||
2.0
|
||||
11
|
||||
0.0
|
||||
21
|
||||
4.0
|
||||
31
|
||||
2.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
120
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
0.0
|
||||
20
|
||||
4.0
|
||||
30
|
||||
2.0
|
||||
11
|
||||
0.0
|
||||
21
|
||||
4.0
|
||||
31
|
||||
0.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
121
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
0.0
|
||||
20
|
||||
6.0
|
||||
30
|
||||
0.0
|
||||
11
|
||||
0.0
|
||||
21
|
||||
6.0
|
||||
31
|
||||
2.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
122
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
0.0
|
||||
20
|
||||
6.0
|
||||
30
|
||||
2.0
|
||||
11
|
||||
0.0
|
||||
21
|
||||
8.0
|
||||
31
|
||||
2.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
123
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
0.0
|
||||
20
|
||||
8.0
|
||||
30
|
||||
2.0
|
||||
11
|
||||
0.0
|
||||
21
|
||||
8.0
|
||||
31
|
||||
0.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
124
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
10.0
|
||||
20
|
||||
2.0
|
||||
30
|
||||
0.0
|
||||
11
|
||||
10.0
|
||||
21
|
||||
2.0
|
||||
31
|
||||
2.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
125
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
10.0
|
||||
20
|
||||
2.0
|
||||
30
|
||||
2.0
|
||||
11
|
||||
10.0
|
||||
21
|
||||
4.0
|
||||
31
|
||||
2.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
126
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
10.0
|
||||
20
|
||||
4.0
|
||||
30
|
||||
2.0
|
||||
11
|
||||
10.0
|
||||
21
|
||||
4.0
|
||||
31
|
||||
0.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
127
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
10.0
|
||||
20
|
||||
6.0
|
||||
30
|
||||
0.0
|
||||
11
|
||||
10.0
|
||||
21
|
||||
6.0
|
||||
31
|
||||
2.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
128
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
10.0
|
||||
20
|
||||
6.0
|
||||
30
|
||||
2.0
|
||||
11
|
||||
10.0
|
||||
21
|
||||
8.0
|
||||
31
|
||||
2.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
129
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
10.0
|
||||
20
|
||||
8.0
|
||||
30
|
||||
2.0
|
||||
11
|
||||
10.0
|
||||
21
|
||||
8.0
|
||||
31
|
||||
0.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
130
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
2.0
|
||||
20
|
||||
8.0
|
||||
30
|
||||
0.0
|
||||
11
|
||||
2.0
|
||||
21
|
||||
8.0
|
||||
31
|
||||
2.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
131
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
2.0
|
||||
20
|
||||
8.0
|
||||
30
|
||||
2.0
|
||||
11
|
||||
4.0
|
||||
21
|
||||
8.0
|
||||
31
|
||||
2.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
132
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
4.0
|
||||
20
|
||||
8.0
|
||||
30
|
||||
2.0
|
||||
11
|
||||
4.0
|
||||
21
|
||||
8.0
|
||||
31
|
||||
0.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
133
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
6.0
|
||||
20
|
||||
8.0
|
||||
30
|
||||
0.0
|
||||
11
|
||||
6.0
|
||||
21
|
||||
8.0
|
||||
31
|
||||
2.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
134
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
6.0
|
||||
20
|
||||
8.0
|
||||
30
|
||||
2.0
|
||||
11
|
||||
8.0
|
||||
21
|
||||
8.0
|
||||
31
|
||||
2.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
135
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
8.0
|
||||
20
|
||||
8.0
|
||||
30
|
||||
2.0
|
||||
11
|
||||
8.0
|
||||
21
|
||||
8.0
|
||||
31
|
||||
0.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
136
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
-5.0
|
||||
20
|
||||
-5.0
|
||||
30
|
||||
0.0
|
||||
11
|
||||
15.0
|
||||
21
|
||||
-5.0
|
||||
31
|
||||
0.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
137
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
15.0
|
||||
20
|
||||
-5.0
|
||||
30
|
||||
0.0
|
||||
11
|
||||
15.0
|
||||
21
|
||||
13.0
|
||||
31
|
||||
0.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
138
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
15.0
|
||||
20
|
||||
13.0
|
||||
30
|
||||
0.0
|
||||
11
|
||||
-5.0
|
||||
21
|
||||
13.0
|
||||
31
|
||||
0.0
|
||||
0
|
||||
LINE
|
||||
5
|
||||
139
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbLine
|
||||
10
|
||||
-5.0
|
||||
20
|
||||
13.0
|
||||
30
|
||||
0.0
|
||||
11
|
||||
-5.0
|
||||
21
|
||||
-5.0
|
||||
31
|
||||
0.0
|
||||
0
|
||||
CIRCLE
|
||||
5
|
||||
140
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbCircle
|
||||
10
|
||||
-2.0
|
||||
20
|
||||
-2.0
|
||||
30
|
||||
0.0
|
||||
40
|
||||
1.0
|
||||
0
|
||||
CIRCLE
|
||||
5
|
||||
141
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbCircle
|
||||
10
|
||||
12.0
|
||||
20
|
||||
-2.0
|
||||
30
|
||||
0.0
|
||||
40
|
||||
1.0
|
||||
0
|
||||
CIRCLE
|
||||
5
|
||||
142
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbCircle
|
||||
10
|
||||
-2.0
|
||||
20
|
||||
10.0
|
||||
30
|
||||
0.0
|
||||
40
|
||||
1.0
|
||||
0
|
||||
CIRCLE
|
||||
5
|
||||
143
|
||||
330
|
||||
1F
|
||||
100
|
||||
AcDbEntity
|
||||
8
|
||||
WALLS
|
||||
100
|
||||
AcDbCircle
|
||||
10
|
||||
12.0
|
||||
20
|
||||
10.0
|
||||
30
|
||||
0.0
|
||||
40
|
||||
1.0
|
||||
0
|
||||
0
|
||||
ENDSEC
|
||||
0
|
||||
183
poweron/appdoc/README_LangDoc.md
Normal file
183
poweron/appdoc/README_LangDoc.md
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
# LangDoc Connector
|
||||
|
||||
Der LangDoc Connector ermöglicht die Integration der LangDoc API in das PowerOn Gateway System. LangDoc ist eine OpenAI-kompatible API, die verschiedene KI-Modelle bereitstellt.
|
||||
|
||||
## Konfiguration
|
||||
|
||||
### Umgebungsvariablen
|
||||
|
||||
Die folgenden Konfigurationsparameter müssen in den entsprechenden Umgebungsdateien gesetzt werden:
|
||||
|
||||
```ini
|
||||
# LangDoc configuration
|
||||
Connector_AiLangdoc_API_URL = https://api.langdock.com/v1/chat/completions
|
||||
Connector_AiLangdoc_API_SECRET = YOUR_LANGDOC_API_KEY_HERE
|
||||
Connector_AiLangdoc_MODEL_NAME = gpt-4o
|
||||
Connector_AiLangdoc_TEMPERATURE = 0.2
|
||||
Connector_AiLangdoc_MAX_TOKENS = 2000
|
||||
```
|
||||
|
||||
### API-Schlüssel erhalten
|
||||
|
||||
1. Melden Sie sich bei Ihrem LangDoc-Konto an
|
||||
2. Navigieren Sie zu den API-Einstellungen
|
||||
3. Generieren Sie einen neuen API-Schlüssel
|
||||
4. Benennen Sie den Schlüssel entsprechend und speichern Sie ihn sicher
|
||||
|
||||
## Verfügbare Funktionen
|
||||
|
||||
### 1. Textgenerierung (`callAiBasic`)
|
||||
|
||||
```python
|
||||
from modules.connectors.connectorAiLangdoc import AiLangdoc
|
||||
|
||||
# Connector initialisieren
|
||||
langdoc = AiLangdoc()
|
||||
|
||||
# Nachrichten für die API vorbereiten
|
||||
messages = [
|
||||
{"role": "user", "content": "Erkläre mir die Grundlagen von Machine Learning"}
|
||||
]
|
||||
|
||||
# API aufrufen
|
||||
response = await langdoc.callAiBasic(messages)
|
||||
print(response)
|
||||
```
|
||||
|
||||
**Parameter:**
|
||||
- `messages`: Liste von Nachrichten im OpenAI-Format (role, content)
|
||||
- `temperature`: Temperatur für die Antwortgenerierung (0.0-1.0, optional)
|
||||
- `maxTokens`: Maximale Anzahl der Tokens in der Antwort (optional)
|
||||
|
||||
### 2. Bildanalyse (`callAiImage`)
|
||||
|
||||
```python
|
||||
# Bildanalyse mit LangDoc Vision
|
||||
prompt = "Beschreibe was du auf diesem Bild siehst"
|
||||
image_path = "/path/to/image.jpg"
|
||||
|
||||
response = await langdoc.callAiImage(prompt, image_path)
|
||||
print(response)
|
||||
```
|
||||
|
||||
**Parameter:**
|
||||
- `prompt`: Prompt für die Bildanalyse
|
||||
- `imageData`: Dateipfad (str) oder Bilddaten (bytes)
|
||||
- `mimeType`: MIME-Typ des Bildes (optional)
|
||||
|
||||
### 3. Verfügbare Modelle auflisten (`listModels`)
|
||||
|
||||
```python
|
||||
# Alle verfügbaren Modelle auflisten
|
||||
models = await langdoc.listModels()
|
||||
for model in models:
|
||||
print(f"Model: {model['id']}")
|
||||
```
|
||||
|
||||
### 4. Modellinformationen abrufen (`getModelInfo`)
|
||||
|
||||
```python
|
||||
# Informationen zu einem spezifischen Modell
|
||||
model_info = await langdoc.getModelInfo("gpt-4o")
|
||||
print(f"Model Details: {model_info}")
|
||||
```
|
||||
|
||||
### 5. Verbindung testen (`_testConnection`)
|
||||
|
||||
```python
|
||||
# Verbindung zur LangDoc API testen
|
||||
is_connected = await langdoc._testConnection()
|
||||
if is_connected:
|
||||
print("Verbindung erfolgreich!")
|
||||
else:
|
||||
print("Verbindung fehlgeschlagen!")
|
||||
```
|
||||
|
||||
## Unterstützte Modelle
|
||||
|
||||
LangDoc unterstützt verschiedene KI-Modelle, darunter:
|
||||
|
||||
- **GPT-4o**: Neuestes OpenAI-Modell mit Vision-Fähigkeiten
|
||||
- **GPT-4**: Hochleistungsmodell für komplexe Aufgaben
|
||||
- **GPT-3.5-turbo**: Schnelles und kosteneffizientes Modell
|
||||
- **Claude 3.5 Sonnet**: Anthropic-Modell über LangDoc
|
||||
- **Gemini Pro**: Google-Modell über LangDoc
|
||||
|
||||
## Verwendung in Workflows
|
||||
|
||||
Der LangDoc Connector kann in PowerOn Workflows verwendet werden:
|
||||
|
||||
```python
|
||||
# Beispiel für Workflow-Integration
|
||||
async def processWithLangDoc(workflow_data):
|
||||
langdoc = AiLangdoc()
|
||||
|
||||
# Textverarbeitung
|
||||
messages = [
|
||||
{"role": "system", "content": "Du bist ein hilfreicher Assistent."},
|
||||
{"role": "user", "content": workflow_data.get("user_input")}
|
||||
]
|
||||
|
||||
result = await langdoc.callAiBasic(messages)
|
||||
return {"ai_response": result}
|
||||
```
|
||||
|
||||
## Fehlerbehandlung
|
||||
|
||||
Der Connector behandelt verschiedene Fehlertypen:
|
||||
|
||||
- **401 Unauthorized**: Ungültiger API-Schlüssel
|
||||
- **429 Too Many Requests**: Rate Limit überschritten
|
||||
- **400 Bad Request**: Ungültige Anfrage
|
||||
- **500 Internal Server Error**: Server-seitige Fehler
|
||||
|
||||
## Sicherheitshinweise
|
||||
|
||||
1. **API-Schlüssel sicher aufbewahren**: Verwenden Sie die Verschlüsselungsfunktionen des Systems
|
||||
2. **Rate Limits beachten**: LangDoc hat eigene Rate Limits
|
||||
3. **Datenvalidierung**: Validiere alle Eingaben vor dem API-Aufruf
|
||||
4. **Logging**: Alle API-Aufrufe werden geloggt für Debugging und Monitoring
|
||||
|
||||
## Beispiel-Anwendungsfälle
|
||||
|
||||
### 1. Dokumentenanalyse
|
||||
```python
|
||||
# Analyse von Dokumenten
|
||||
messages = [
|
||||
{"role": "user", "content": f"Analysiere dieses Dokument: {document_text}"}
|
||||
]
|
||||
analysis = await langdoc.callAiBasic(messages)
|
||||
```
|
||||
|
||||
### 2. Code-Generierung
|
||||
```python
|
||||
# Code-Generierung
|
||||
messages = [
|
||||
{"role": "user", "content": "Schreibe eine Python-Funktion für die Berechnung von Fibonacci-Zahlen"}
|
||||
]
|
||||
code = await langdoc.callAiBasic(messages)
|
||||
```
|
||||
|
||||
### 3. Übersetzung
|
||||
```python
|
||||
# Textübersetzung
|
||||
messages = [
|
||||
{"role": "user", "content": f"Übersetze folgenden Text ins Englische: {german_text}"}
|
||||
]
|
||||
translation = await langdoc.callAiBasic(messages)
|
||||
```
|
||||
|
||||
### 4. Zusammenfassung
|
||||
```python
|
||||
# Textzusammenfassung
|
||||
messages = [
|
||||
{"role": "user", "content": f"Fasse folgenden Text zusammen: {long_text}"}
|
||||
]
|
||||
summary = await langdoc.callAiBasic(messages)
|
||||
```
|
||||
|
||||
## Support und Dokumentation
|
||||
|
||||
- **LangDoc API Dokumentation**: https://docs.langdock.com/
|
||||
- **LangDoc Website**: https://www.langdock.com/
|
||||
- **PowerOn Gateway Dokumentation**: Siehe README.md im Hauptverzeichnis
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue