Using MAXScript to create a house?

jeffmorris
Advocate
Advocate

Using MAXScript to create a house?

jeffmorris
Advocate
Advocate

I want to write MAXScript file to create 3D models of houses after I enter number of floors, length, and width in a dialog box. How do I create a dialog box? Is there a different kind of extrude command? One end of the house is open instead of closed. Is there a different way of drawing the house shape before extruding it? Are there good written tutorials on MAXScript?

0 Likes
Reply
1,721 Views
13 Replies
Replies (13)

MedalHellWay
Collaborator
Collaborator

From Autodesk 3dsmax Learning Channel:

 

https://www.youtube.com/watch?v=kc1lZ7fyaqs&list=PLnKw1txyYzRmwWJ1K7tlBSjiy42YVZ86K

 

Here use of a free script called Building Maker 😉

0 Likes

MedalHellWay
Collaborator
Collaborator

Ok, In addition to the advice that I have stated above, I have created a script for you called "Quick Create House". See if you can be helpful and studies the creation code 🙂

 

0 Likes

jeffmorris
Advocate
Advocate

Thank you very much for the CreateQuickHouse script. I made some changes to the script so that I got it working the way I want. How do I have the script create the house where I click in the 3D world?

0 Likes

MedalHellWay
Collaborator
Collaborator
Yes, you can; find on maxscript help "mouse tools"
0 Likes

jeffmorris
Advocate
Advocate

How can I use mouse tools in my script? What about pickpoint()? How can I break Point3 into three separate parts and put the parts into the below line?

 

pl = Plane length:floorheight1 width:sp_width.value pos:[0,0,floorheight2] isSelected:on widthsegs:1 lengthsegs:1

0 Likes

MedalHellWay
Collaborator
Collaborator
See "Scripted Mouse Tools" in help and follow more example to use the mouse tool. Sorry, but I don't never used MT, but the example are meaning...
0 Likes

MedalHellWay
Collaborator
Collaborator

Mmmhhh try this but it is to be fix... more than this I don't know :D

 

	on bt_create pressed do 
	(
		tool create
(

on mousePoint clickno do
if clickno == 1 then createHouse() else #stop
on mouseMove clickno do pl.pos = gridPoint
)
startTool create
	)

 

0 Likes

jeffmorris
Advocate
Advocate

I think I got the script working. In the MAXScript Help, there is a function that finds angle of a line between two points. I would like to make two clicks, find angle of a line between two points, and draw a house at an angle. Will this work?

 

Vector Dot Product

dot <point3> <point3>

Returns the vector dot product.

The geometric interpretation of the dot product is the length of the projection of the first vector onto the unit vector of the second vector. Obviously, when the two vectors are perpendicular, the dot product is 0.0.

The dot product is commutative, which means that dot X Y == dot Y X.

The dot product is associative, which means that dot (r*X) Y == r*(dot X Y).

The dot product is distributive, which means that dot X (Y+Z) == (dot X Y) + (dot X Z).

Because the dot product of two normal vectors is the cosine of the angle between them, the dot product can be used conveniently to calculate the angle between two vectors:

 

FOR EXAMPLE

fn GetVectorsAngle v1 v2 =
(theAngle = acos(dot (normalize v1) (normalize v2))
)
GetVectorsAngle [10,0,0] [10,20,0]
63.435
0 Likes

MedalHellWay
Collaborator
Collaborator
I don't understand.. you want that the position of one corner of the house is same of the pisition angle or that the corner wall of house is same of the angle??
0 Likes

jeffmorris
Advocate
Advocate

Here is the screenshot showing you how I want the script to rotate the house to match the angle of the gray rectangle. house01.PNG

0 Likes

MedalHellWay
Collaborator
Collaborator

Try and adjust it!! 😄

 

rollout test "Test"
(
	button cb ""

	fn GetVectorsAngle v1 v2 = (theAngle = acos(dot (normalize v1) (normalize v2)) )
	on cb pressed do
	(
		
		for c = 1 to 2 do
		(
		ClickPos = pickPoint snap:#3D ()
		Point name:((uniquename "PointClickPos") as string) pos:ClickPos
		)
		gv = GetVectorsAngle $PointClickPos001.pos $PointClickPos002.pos
		rotate $ (angleaxis gv[0,0,1])
		delete $PointClickPos001
		delete $PointClickPos002
	)
	
)
createdialog test

 

0 Likes

jeffmorris
Advocate
Advocate

I found out that 3DS MAX 2016 has a new feature called "MAX Creation Graph". Is it possible to move the code to MCG?

0 Likes

MedalHellWay
Collaborator
Collaborator
I think of yes, but I have not tried MCG...
0 Likes