Failed to attach map when modeling maps in python
I want to explain the BIMBase installation path in D disk because I want to use the map in the BIMBase library. Turn to < a href = "https://blog.csdn.net/weixin_43284694/article/details/116062024?spm=1001.2014.3001.5502" target="_blank">
BIMBase Python
The parameterized component library manual just found a way to use python maps
Example code is as follows
class 长方体(Component):
def __init__(self):
Component.__init__(self)
self['长'] = Attr(1000, obvious = True, combo = [500,1000,2000,3000,4000])
self['宽'] = Attr(300.0, obvious = True)
self['高'] = Attr(500, obvious = True)
self['长方体'] = Attr(None, show = True)
self.replace()
@export
def replace(self):
L = self['长']
W = self['宽']
H = self['高']
TestCube = scale(L,W,H) * Cube()
self['长方体'] = TestCube
self['长方体'].material('M8')
if __name__ == "__main__":
mt3 = create_material('M8', mapMode = 5, mapUnit = 0, uvScale = [1,1],
wRotation = 0)
mt3.mapFile = R'C:\Users\PKPM\Pictures\BIMBase 图标.png'
FinalGeometry = 长方体()
place(FinalGeometry)
The final result is
I write the
code according to the example method as follows
from pyp3d import *
class 椅子(Component):
def __init__(self):
Component.__init__(self)
self['H'] = Attr(840,obvious=True)
self['W'] = Attr(500,obvious=True)
self['L'] = Attr(520,obvious=True)
self['椅子'] = Attr(None,show=True)
self.replace()
@export
def replace(self):
H = self['H']
W = self['W']
L = self['L']
r = 100
R = 50
背靠1 = Ellipse(Vec3(-410/2,0,380/2),Vec3(r,0,0),Vec3(0,0,r),pi/2,pi/2)
背靠2 = Ellipse(Vec3(-410/2,0,-380/2),Vec3(r,0,0),Vec3(0,0,r),pi,pi/2)
背靠3 = Ellipse(Vec3(410/2,0,-380/2),Vec3(r,0,0),Vec3(0,0,r),pi/2*3,pi/2)
背靠4 = Ellipse(Vec3(410/2,0,380/2),Vec3(r,0,0),Vec3(0,0,r),0,pi/2)
背靠 = ContourLine([背靠1,背靠2,背靠3,背靠4])
背靠 = ExtrusionPlus([背靠],Vec3(0,10,0))
背靠支住1 =Cone(Vec3(-250,0,-500/2),Vec3(250,0,-500/2),R)
背靠支住2 =Cone(Vec3(-250,-10,-520/2),Vec3(250,-10,-520/2),R)
背靠支住3 =Cone(Vec3(-300,-10,-520/2),Vec3(300,-10,-520/2),20)
背靠支住 = trans(0,190,-190) * rotx(-0.35*pi) * (背靠支住1 - 背靠支住2)
背靠支住 = 背靠支住-背靠支住3
座垫1 = Ellipse(Vec3(-500/2,-100,-350),Vec3(R,0,0),Vec3(0,R,0),pi/2,pi/2)
座垫2 = Ellipse(Vec3(-500/2,-500,-350),Vec3(R,0,0),Vec3(0,R,0),pi,pi/2)
座垫3 = Ellipse(Vec3(500/2,-500,-350),Vec3(R,0,0),Vec3(0,R,0),pi/2*3,pi/2)
座垫4 = Ellipse(Vec3(500/2,-100,-350),Vec3(R,0,0),Vec3(0,R,0),0,pi/2)
座垫 = ContourLine([座垫1,座垫2,座垫3,座垫4])
座垫 = trans(0,0,5) * ExtrusionPlus([座垫],Vec3(0,0,-10))
左桌脚 = FilletPipe([Vec3(-550/2,-50,-700),Vec3(-500/2,-100,-370),Vec3(-500/2,-500,-370),Vec3(-550/2,-550,-700)],[0,40,40,0],20)
右桌脚 = FilletPipe([Vec3(550/2,-50,-700),Vec3(500/2,-100,-370),Vec3(500/2,-500,-370),Vec3(550/2,-550,-700)],[0,40,40,0],20)
self['椅子'] = Combine(背靠+背靠支住,座垫,左桌脚,右桌脚)
self['椅子'].material('M1')
if __name__ == "__main__":
mt3 = create_material('M1',mapMode = 0,mapUnit = 0, uvScale = [1,1],
wRotation = 0)
mt3.mapFile = 'D:\BIMBase\BIMBase建模软件-2023\Support\Chart\木材02.jpg'
place(椅子())
>
>
In other words, create_material() is not working,
Render the model by attaching python modeling maps directly to the model instead of using software maps