Home Technical Talk

[3DS MAX] - Create Splines based on helpers

Keith01
polycounter lvl 7
Offline / Send Message
Keith01 polycounter lvl 7
Hi,

I'm currently trying to create wires for overhead lines for an electric tram. There will be over 4,000 of these OHLs and I was thinking of using helpers for the contact points of the wires (4 wires each) and then attaching the vertices using the helpers and a spline.
To Note: The levels will change where these are placed and also the positioning.

Question: Does anyone know a way to create a spline, where as, the spline will stick and create verts only on the helpers selected? 

I hope I'm making myself clear.

Thanks in advance.
 

Replies

  • Klunk
    Options
    Offline / Send Message
    Klunk ngon master
    macroScript spline_from_selection
    			category:"Claudes Utils" 
    			tooltip:"create spline from selection pivots" 
    			ButtonText:"sfroms"
    			icon:#("HairAndFur", 3)
    (
    	on execute do 
    	(
    		if selection.count >= 2 then
    		(
    			local spl = splineShape();
    			local crv = addnewSpline spl;
    			for s in $selection do addKnot spl crv #corner #line s.pos;
    			updateShape spl;
    			forceCompleteRedraw();
    		)		
    	)		
    	on isEnabled do selection.count >= 2
    )
    just select the points in the order you want the spline to go in
  • Keith01
    Options
    Offline / Send Message
    Keith01 polycounter lvl 7
    Sorry only seeing this now. I'll give it a go and see how I get on. Thank you.
  • Keith01
    Options
    Offline / Send Message
    Keith01 polycounter lvl 7
    Hi Klunk. 

    I ran the script after selecting the helpers in the order I wanted and nothing seems to happen when I run it.
  • Klunk
    Options
    Offline / Send Message
    Klunk ngon master
    after you run it, attach it as a macro to a tool bar button.

    right click on any tool bar, select customize....
    it'll take a while to load
    on the toolbar tab
    press new...
    set the name and ok.
    in category drop down select "claudes utils"
    now drag the item "create spline from selection pivots"  onto the new toolbar
    now press save and ok as all responses.

    now select the nodes in order and press the new button.
  • Keith01
    Options
    Offline / Send Message
    Keith01 polycounter lvl 7
    You legend. That works perfectly. You've saved me loads of time.
  • Klunk
    Options
    Offline / Send Message
    Klunk ngon master
    there are other approaches you could go for, for example create a custom attribute for per type of cable tower (only once as it should be cloned with the tower mesh), with the say index of each vertex that represents where the cable goes. It's then a similar script that works on selected towers and should be able to create multiple shapes at once.
  • pxgeek
    Options
    Offline / Send Message
    pxgeek keyframe
    Nice, Klunk!!

    I was going to suggest to have the spline connect by ordered numbering so user won't need to click each dummy one by one...but found that you can batch select with scene explorer and it'll do it automatically :)

    One issue I found though was that I couldn't change the corner type of the points after the fact...it always stays as "corner" regardless.
  • Klunk
    Options
    Offline / Send Message
    Klunk ngon master
    yeah you need to select as sub object level spline, right click and change from line to curve. 
    or change #line to #curve in the script

  • pxgeek
    Options
    Offline / Send Message
    pxgeek keyframe
    Oh, duh...
    Thank you!
  • Klunk
    Options
    Offline / Send Message
    Klunk ngon master
    here's a "fun" addition

    macroScript spline_from_selection
    			category:"Claudes Utils" 
    			tooltip:"create spline from selection pivots" 
    			ButtonText:"sfroms"
    			icon:#("HairAndFur", 3)
    (
    
    	
    	fn new_point3_expression_controller scrc targ =
    	(	
    		expr = point3_expression();
    		expr.AddVectorTarget "position" targ.position.controller;
    		expr.AddVectorTarget "offset" scrc.position.controller;
    		expr.SetExpression "position - offset";
    		expr;
    	)
    	on execute do 
    	(
    		if selection.count >= 2 then
    		(
    			local spl = splineShape();
    			local crv = addnewSpline spl;
    			for s in $selection do addKnot spl crv #corner #line s.pos;
    			updateShape spl;
    			
    			animateVertex spl #all;
    			mc = spl[#Object__Editable_Spline][#master];
    			
    			if mc != undefined then
    			(	
    				nknots = numKnots spl crv;
    				for k = 1 to nknots do
    				(	
    					subanim_index = 2 + (k - 1) * 3;
    					mc[subanim_index].controller = new_point3_expression_controller spl selection[k]
    				)
    			)	
    			forceCompleteRedraw();
    		)		
    	)		
    	on isEnabled do selection.count >= 2
    )
    ties the knots to the points, though you can move the base splines position you'll break it if you rotate it (would require a change to script controller to fix that)

    be nice if the per line hilite for code wasn't so "harsh" also when adding code the settings make it impossible to read looking like....
     
    the odd thing is it looks fine directly after adding it but once you leave and the return it looks decidedly shit :) 
  • Klunk
    Options
    Offline / Send Message
    Klunk ngon master
    also for the above script changing the knot type or spline type will remove the knot animation controllers
  • pxgeek
    Options
    Offline / Send Message
    pxgeek keyframe
    Neat!
    Now if only max had the option for one-sided poly strips in spline rendering rollout...you've got the beginnings of a great hair cards tool :wink:
  • Klunk
    Options
    Offline / Send Message
    Klunk ngon master
    lucky I wrote my own lofter with a built in line profile

    you can do the same with the sweep modifier and custom simple line profile. it's interesting but I don't think you win much over just tweaking the spline knots directly  :/
  • pxgeek
    Options
    Offline / Send Message
    pxgeek keyframe
    Ahh...forgot about sweep, thanks for that.

    Loft has some extremely powerful functions, like deformations. But good grief do I hate it's interface! Ideally, this made up tool would combine loft and sweep into a single modifier that can draw and edit strips parametrically, without the need to select separate instanced objects.
    Having helpers just makes it quicker to edit shapes, specifically when dealing with lots of separate splines and having to go in and out of sub-object mode.

    Anyway, sorry OP for going off topic
  • Keith01
    Options
    Offline / Send Message
    Keith01 polycounter lvl 7
    Very cool. And don't worry go off topic as much as possible. A small spark and cause a big flame. Would be interesting to see what other applications can be used for this too. 
  • Keith01
    Options
    Offline / Send Message
    Keith01 polycounter lvl 7
    Hi.

    I used the latest updated script and when I use it on an open group all the verts on the spline jump to the origin of the world.
Sign In or Register to comment.