Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

maxScript

maxScript

Anonymous
Not applicable
1,460 Views
11 Replies
Message 1 of 12

maxScript

Anonymous
Not applicable
Hello guys,
Can any one help me need script that create polygon from verices each vertex is 3d point
Then assign material to it
0 Likes
Accepted solutions (3)
1,461 Views
11 Replies
Replies (11)
Message 2 of 12

Swordslayer
Advisor
Advisor
Accepted solution
vertices = #([43,-20,0], [27,8,0], [-6,8,0], [-23,-20,0], [-6,-50,0], [27,-50,0])
obj = convertToPoly (mesh vertices:vertices faces:#())
polyOp.createPolygon obj #(1,2,3,4,5,6)
obj.material = standardMaterial()
redrawViews()
0 Likes
Message 3 of 12

Anonymous
Not applicable
But need to add material from jpg file on my computer
0 Likes
Message 4 of 12

Swordslayer
Advisor
Advisor
In that case replace the standardMaterial() part with standardMaterial diffuseMap:(bitmapTexture filename:@"C:\path\to\texture\filename.jpg")
0 Likes
Message 5 of 12

Anonymous
Not applicable
unfortunately tried this but not work
0 Likes
Message 6 of 12

Swordslayer
Advisor
Advisor
That's like.. super unhelpful. You're doing something wrong and without showing the code/error message or telling me what expectations of yours aren't met, it's impossible to tell you what to change. Does the file exist at the path? When you pick the material from the object, is there anything wrong? Maybe you just wanted the texture to show in the viewport (which it doesn't by default) or maybe you wanted to apply mapping as well or... well, you tell me, I could guess all day and still not get it.
0 Likes
Message 7 of 12

Anonymous
Not applicable
sorry i am newer to maxscript
when i add image file from my folder it appear as standardmaterial
but when drag and drop it appear color of material not texture itself
these images
0 Likes
Message 8 of 12

Anonymous
Not applicable

i tried to solve it by 

add this line

showtexturemap mat true

 

as code to draw face became

 

depth = 100
width = 100
vertices = #([0, 0, 0],[width, 0, 0],[width, depth, 0],[0, depth, 0] )
obj = convertToPoly (mesh vertices:vertices faces:#())
polyOp.createPolygon obj #(1,2,3,4)
img_path = "E:/images.jpg"
mat=standardmaterial();
mat.diffuseMap = bitmapTexture filename:(img_path)
showtexturemap mat true

obj.material=mat
redrawViews()

now it work like drag and drop but this and drage and drop not clear as whenn create plan 

these 2 image can explain 

Capture.PNGCapture.PNG

0 Likes
Message 9 of 12

Anonymous
Not applicable

i tried to solve it by 

add this line

showtexturemap mat true

 

as code to draw face became

 

depth = 100
width = 100
vertices = #([0, 0, 0],[width, 0, 0],[width, depth, 0],[0, depth, 0] )
obj = convertToPoly (mesh vertices:vertices faces:#())
polyOp.createPolygon obj #(1,2,3,4)
img_path = "E:/images.jpg"
mat=standardmaterial();
mat.diffuseMap = bitmapTexture filename:(img_path)
showtexturemap mat true

obj.material=mat
redrawViews()

now it work like drag and drop but this and drage and drop not clear as whenn create plan 

these 2 image can explain 

Capture.PNGCapture.PNG

0 Likes
Message 10 of 12

Swordslayer
Advisor
Advisor
Accepted solution

That's because there's no mapping info, you can either add a uvwmap modifier with given size or use the polyop methods to add the mapping/mapping verts+faces.

0 Likes
Message 11 of 12

Anonymous
Not applicable
polyop.applyUVWMap <Poly poly> \
<#planar | #cylindrical | #spherical | #ball | #box> | <#face> \
utile:<float=1.0> vtile:<float=1.0> wtile:<float=1.0> \
uflip:<boolean=false> vflip:<boolean=false> wflip:<boolean=false> \
cap:<boolean=true> tm:<Matrix3=identity matrix> channel:<integer=1>

found this map but also not work well
0 Likes
Message 12 of 12

Anonymous
Not applicable
Accepted solution

worked well by this line

polyop.applyUVWMap poly\
#face \

0 Likes