PDA

View Full Version : 3D Object Inserter


james120479
08-18-2009, 09:10 AM
Does anyone know if a script exists for inserting / merging an existing 3D model / object into a scene file and dropping onto a surface where picked? i.e. you have a model of a car in a seperate max file and want to drop this onto a surface in your scene, dropping at the point you specify with a click of a mouse

j-man
08-18-2009, 11:51 AM
Hi James,

There are plenty of tools for placing objects onto a mesh, search at scriptspot.

why can't you just merge it in yourself?

J.

james120479
08-18-2009, 12:06 PM
Cheers, i'm particularly looking for something that will insert from external file and place on surface where i pick in one step, rather than the 3 steps of merging the file, moving to correct x,y postion and then moving to the surface. I have a fairly large number of objects to 'drop' in which could take some time and was just wondering if there was a quicker automated method

james120479
08-18-2009, 04:32 PM
Cheers, i'm particularly looking for something that will insert from external file and place on surface where i pick in one step, rather than the 3 steps of merging the file, moving to correct x,y postion and then moving to the surface. I have a fairly large number of objects to 'drop' in which could take some time and was just wondering if there was a quicker automated method

AkramParvez
08-19-2009, 07:03 AM
try this ...

try(destroyDialog mergePlace)catch()

fn PlaceObj msg ir obj faceNum shift ctrl alt =
(
if ir == undefined then
myStr = mouse.pos
else
myStr = ir.pos
case msg of
(
#mousePoint:
(
Object1.pos = myStr
)
#mouseAbort:
(
destroyDialog mergePlace
exit
)
)
#continue
)

global Object1
global terr
rollout mergePlace "Merge"
(
button OpnFile "Open Merge File"
pickbutton chooseit "Pick Object to be Placed On"
button place "Place" width:130 height:40
button Abt "(,\")"

on Abt pressed do
(
rollout abut "About"
(
label a1 "Written By Akram(Akira)"
hyperLink blog "akira-techart.blogspot.com" address:"http://akira-techart.blogspot.com/"
)
createDialog abut
)

on OpnFile pressed do
(
fl = getOpenFileName caption: "Merge File" types:"3ds Max (*.max)|*.max"
if fl != undefined then
(
objs = getMAXFileObjectNames fl
if objs.count > 1 then
mergeMaxFile fl #prompt #select
else
mergeMaxFile fl #select
Object1 = selection
OpnFile.text = filenameFromPath fl
)
)

on chooseit picked sel do
(
if sel != undefined do
(
terr = sel
chooseit.text = terr.name
)
)

on place pressed do
(
mouseTrack on:terr snap:#3D trackCallback:PlaceObj
)
)

createDialog mergePlace

james120479
08-20-2009, 08:03 AM
Thank you so much Akram! This works perfectly... one last thing as i'm totally new to the use of scripts. To get this to work i choose run script from the MAXScript menu which works fine. However I have to do this everytime i start Max, is there a way of keeping this permanently loaded on the Maax toolbar so i don't have to load everytime I load Max?

AkramParvez
08-20-2009, 11:59 AM
copy the code into a text file and save as MergeNPlace.mcr in your 3dsMax_root_folder/UI/Macroscripts/ then close and run max.
Go to customize user interface --> ToolBar --> Category Akira Scripts and drag-n-drop the MergeNPlace into ur toolbar... Enjoy.


macroScript MergeNPlace category:"Akira Scripts"
(
try(destroyDialog mergePlace)catch()

fn PlaceObj msg ir obj faceNum shift ctrl alt =
(
if ir == undefined then
(
myStr = mouse.pos
)
else
(
myStr = ir.pos
--Rot= (inverse(matrixfromNormal ir.dir)) as EulerAngles
)
case msg of
(
#mousePoint:
(
--if Rot != undefined then Object1.rotation = Rot
Object1.pos = myStr
)
#mouseAbort:
(
destroyDialog mergePlace
exit
)
)
#continue
)

global Object1 = undefined
global terr = undefined
rollout mergePlace "Merge"
(
button OpnFile "Open Merge File"
pickbutton chooseit "Pick Object to be Placed On"
button place "Place" width:130 height:40
button Abt "(,\")"

on Abt pressed do
(
rollout abut "About"
(
label a1 "Written By Akram(Akira)"
hyperLink blog "akira-techart.blogspot.com" address:"http://akira-techart.blogspot.com/"
)
createDialog abut
)

on OpnFile pressed do
(
fl = getOpenFileName caption: "Merge File" types:"3ds Max (*.max)|*.max"
if fl != undefined then
(
objs = getMAXFileObjectNames fl
if objs.count > 1 then
mergeMaxFile fl #prompt #select
else
mergeMaxFile fl #select
Object1 = selection
OpnFile.text = filenameFromPath fl
)
)

on chooseit picked sel do
(
if sel != undefined do
(
terr = sel
chooseit.text = terr.name
)
)

on place pressed do
(
mouseTrack on:terr snap:#3D trackCallback:PlaceObj
)
)

createDialog mergePlace
)

james120479
08-20-2009, 12:25 PM
Cheers so much... this works a treat!

CGTalk Moderation
08-20-2009, 12:25 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.