Announcement

Collapse
No announcement yet.

Calling all Scripters :) custom script needed :)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Calling all Scripters :) custom script needed :)

    Hi Guys,

    I have a project where I need to create copies of 100's of very simple products ("boxes" basically) and modifying the heights of each one (by the same amount), and repeating this process, to generate thousands of products just from those 100's......

    So obviously I'm thinking of a script that'll take care of all of this.

    'All' I need it to do to these copies is the following......

    1) Add an Edit-Poly Modifier to the object, and apply a check to "Preserve UVs" so that it is checked, then go into "Vertex Selection Mode".

    2) Select the bottom-most vertices (there'll only be either 2 or 4 of those there and they'll all be at z=0, so that's the easiest way those can be found),

    3) Then invert the Selection, so you have all the topmost vertices selected now (they'll be many vertices selected, not just 2 or 4).

    4) Move those now selected vertices either up or down a specified amount (which I'll hard code that into the script, as I think that would be easiest).

    5) Job done, turn off Edit-Poly Modifier.

    6) Now re-name that new object with a suffix of Original Name, removing its last three characters first and replacing those with a new 3 char value that I will provide.

    7) Then repeat this same process for the rest of these newly created objects in the scene.

    Now that sounds easy to do but I have never scripted anything in my life before.....

    But maybe now is a good time to learn.... (it's the learning curve I fear for some reason.....)

    .....or just ask / pay someone to do this for me

    Wish me luck guys! (I'm watching MaxScript101 right now ).
    Jez

    ------------------------------------
    3DS Max 2023.3.4 | V-Ray 6.10.08 | Phoenix FD 4.40.00 | PD Player 64 1.0.7.32 | Forest Pack Pro 8.2.2 | RailClone 6.1.3
    Windows 11 Pro 22H2 | NVidia Drivers 535.98 (Game Drivers)

    Asus X299 Sage (Bios 4001), i9-7980xe, 128Gb, 1TB m.2 OS, 2 x NVidia RTX 3090 FE
    ---- Updated 06/09/23 -------

  • #2
    Originally posted by JezUK View Post
    But maybe now is a good time to learn.... (it's the learning curve I fear for some reason.....)
    I can only recommend this, learning to script is very valuable. And what you describe is fairly easy so would probably be a good project to start on.

    /Thomas

    www.suurland.com
    www.cg-source.com
    www.hdri-locations.com

    Comment


    • #3
      I don't think you will actually need maxscript for this. Can't you just select all these boxes apply an editable poly modifier on top of all of them, select like you said then do the things you want using some transform randomizer script. Collapse all these objects and use rename object tool from Max itself.

      edit: The transformation might be a problem as those scripts probably don't take into account which object they belong to.
      Last edited by Vizioen; 02-10-2021, 05:10 AM.
      A.

      ---------------------
      www.digitaltwins.be

      Comment


      • #4
        Originally posted by suurland View Post

        I can only recommend this, learning to script is very valuable. And what you describe is fairly easy so would probably be a good project to start on.

        /Thomas

        Thanks Thomas for the encouragement - you're right, I think that too, it is a good project to start on.

        I've actually almost written my very first script , yay it's about 10 lines long, cobbled from one place and another.....

        This first script is a copier/renamer, because that's the first step I need to accomplish for my project - copying and renaming a ton of objects (it'll have around 4200 products in my scene, all very, very lightweight and small btw).

        Those 10-20 lines have taken me (embarrassed emojicon here.....) over a day to get to...... and it still doesn't work (well it does if I forget the rollout box and just hard code the oldprofile/newprofile values within " " quotes.... (so it's very, very close, I think I know what the problem is I think, I just can't find my way the manuals and the learning curve is very steep for me);

        Here it is..... (what I want this script to do is copy a bunch of objects, all of which will have within their object name a Profile Code, say "075", and I want the newly created copies of those objects to have the same name structure, only replacing that Old Profile Code with a New Profile Code, eg "145".


        macroScript CopierRenamer category: "HowTo"
        (
        try (closerolloutfloater CopierRenamer) catch()

        rollout CopierRenamer "CopierRenamer 0.55"
        (

        --Layout of Dialog Box
        edittext oldprofile "Old Profile Number: " fieldWidth:100
        edittext newprofile "New Profile Number: " fieldWidth:100
        button create_them "Create New Objects"

        on create_them pressed do
        (
        --clone the selected objects
        maxOps.cloneNodes (selection as array) cloneType:#copy newNodes:&nnl #nodialog

        --Loop through the array of object it returns
        for i = 1 to selection.count do
        (
        --rename the objects to a unique name
        objectname = selection[i].name
        nnl[i].name = substituteString objectname oldprofile newprofile
        )
        )


        )
        CreateDialog CopierRenamer width:250 height:95
        )


        I believe the issue is that the edittext is one type of field (not a string?) and the substituteString doesn't like their field type?

        Any helpers please?
        Last edited by JezUK; 02-10-2021, 07:12 AM.
        Jez

        ------------------------------------
        3DS Max 2023.3.4 | V-Ray 6.10.08 | Phoenix FD 4.40.00 | PD Player 64 1.0.7.32 | Forest Pack Pro 8.2.2 | RailClone 6.1.3
        Windows 11 Pro 22H2 | NVidia Drivers 535.98 (Game Drivers)

        Asus X299 Sage (Bios 4001), i9-7980xe, 128Gb, 1TB m.2 OS, 2 x NVidia RTX 3090 FE
        ---- Updated 06/09/23 -------

        Comment


        • #5
          So a couple of things - I'm in the middle of a few things so can't run the full thing right now but you've got your aim a bit wrong. OldProfile and NewProfile in your script are both edit text objects, so you're trying to feed a ui element into the substring command which only wants text. Now if you were to try something like OldProfile.text and NewProfile.text you'd probably get a string back which substring would be more happy with. Same way that if you're using a spinner control to set a multiplier for the selected lights and do something like light.multiplier = spinner, you're trying to set the light's value to the spinenr ui control rather than the number in the spinner which would be spinner.value.

          Comment


          • #6
            Originally posted by joconnell View Post
            So a couple of things - I'm in the middle of a few things so can't run the full thing right now but you've got your aim a bit wrong. OldProfile and NewProfile in your script are both edit text objects, so you're trying to feed a ui element into the substring command which only wants text. Now if you were to try something like OldProfile.text and NewProfile.text you'd probably get a string back which substring would be more happy with. Same way that if you're using a spinner control to set a multiplier for the selected lights and do something like light.multiplier = spinner, you're trying to set the light's value to the spinenr ui control rather than the number in the spinner which would be spinner.value.
            joconnell, thank you soooooo much.

            I spent all of yesterday trying to figure this out..... (I guess that's the price I'll have to pay to learn this stuff.....).

            I looked online, videos, forums, in the Maxscript help docs (which for a beginner is like looking for a needle in a haystack, and that's assuming you know that it's a needle you should be looking for....).

            But you explaining that simple concept re UI and text, helped me enormously. Thank you.

            That first script is step one..... now for the biggy, step 2 of this process

            Jez

            ------------------------------------
            3DS Max 2023.3.4 | V-Ray 6.10.08 | Phoenix FD 4.40.00 | PD Player 64 1.0.7.32 | Forest Pack Pro 8.2.2 | RailClone 6.1.3
            Windows 11 Pro 22H2 | NVidia Drivers 535.98 (Game Drivers)

            Asus X299 Sage (Bios 4001), i9-7980xe, 128Gb, 1TB m.2 OS, 2 x NVidia RTX 3090 FE
            ---- Updated 06/09/23 -------

            Comment


            • #7
              Yep I agree, the docs can be a bit tough for some of the basics - one thing I'd recommend is the lovely Dave_Wortley 's blog - https://davewortley.wordpress.com/ - it's got a few good fundamentals about using the error output to see where things are breaking and what they were expecting. Also what's great is anything big i've ever written is a tonne of small easy things all chained together.

              Comment

              Working...
              X