Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- create_chevron_lines
- v1.00
- 240118
- should take top left of the bbox and bottom right corner and create a unit vector.
- the section moves along that unit vector from 1 coord to the other buy the chevron distance
- try make a series of dummys that occupy the point that the section will exist.
- v1.01
- 240119
- I changed from dealing with chevrons moving along a vector from top left to bottom right of the bbox
- Instead the section takes up the center point plus twice the diagonal bbox
- Then the section is moved in the objects local transform the chevron gap distance to acheive a regular gap
- v1.02
- 240920
- now works on multiple shapes and does more error checking.
- tries to be more optimal with the chevron padding.
- */
- (
- local chevron_gap = 3.0
- local chevron_angle = 0.0
- fn clusterAttachShapes objArr _newName = --attaches and renames objects
- (
- local newName = (uniqueName (_newName+"-00"))
- j = 1
- count = objArr.count
- undo off
- (
- while objArr.count > 1 do
- (
- addandweld objArr[j] objArr[j+1] -1 --$Line001 $Line002 -1
- deleteItem objArr (j+1)
- j += 1
- if (j + 1) > objArr.count then j = 1
- )
- )
- objArr[1].name = newName
- select (getNodeByName newName)
- )
- fn Knots_to_corner _spl =
- (
- for i = 1 to numKnots _spl do
- (
- setKnotType _spl 1 i #corner
- )
- updateShape _spl
- )
- if (selection.count == 0) then
- (
- messagebox "You must select atleast 1 shape!"
- ) else
- (
- shapes_array = for i in selection where superclassof i == shape collect i
- for i in shapes_array do
- (
- max create mode
- convertTo i splineShape
- DisableSceneRedraw()
- if (numsplines i == 1) and (isClosed i 1) do with undo off
- (
- select i
- -- defining a shape to create chevrons within, this will use the selected spline in the future
- the_shape = i
- IsolateSelection.EnterIsolateSelectionMode()
- -- make a poly version of the shape for use with the section tool
- the_shape_as_poly = copy the_shape
- addModifier the_shape_as_poly (Edit_Poly())
- -- create the section
- the_section = section width:10 length:10
- -- take on the orientation of the shape
- the_section.transform = the_shape.transform
- --lay it down flat
- in coordsys local rotate the_section (angleaxis 90 [1,0,0])
- -- rotate it to the desired angle
- in coordsys local rotate the_section (angleaxis chevron_angle [0,1,0])
- -- get the amount of required chevrons to be generated
- the_distance = (distance [the_shape.min.x, the_shape.max.y, 0] [the_shape.max.x, the_shape.min.y, 0])
- amount_of_chevrons = (the_distance * 1.5 / chevron_gap) as integer
- -- set the first location of the section to create a chevron
- init_chevron_pos_obj = dummy pos:the_shape.center
- init_chevron_pos_obj.transform = the_shape.transform
- in coordsys local move init_chevron_pos_obj [0,the_distance,0]
- initial_chevron_position = init_chevron_pos_obj.pos
- delete init_chevron_pos_obj
- -- create the chevron lines
- for i = 1 to amount_of_chevrons do
- (
- new_section = copy the_section
- new_section.pos = initial_chevron_position
- chevron_offset = chevron_gap * i as float
- in coordsys local move new_section ([0,0,chevron_offset])
- EnableSceneRedraw()
- max views redraw
- DisableSceneRedraw()
- new_chevron = convertToSplineShape new_section --SplineShape
- new_chevron.wireColor = color 253 152 0
- new_chevron.name = uniqueName "LM_temp_chevron-"
- )
- delete $Section*
- delete the_shape_as_poly
- clusterAttachShapes ($LM_temp_chevron* as array) "LM_chevron"
- -- convert knots to corner type
- max modify mode
- subobjectLevel = 1
- actionMan.executeAction 0 "40021"
- weldSpline $ 0.001
- subobjectLevel = 0
- max create mode
- IsolateSelection.ExitIsolateSelectionMode()
- addModifier $ (Optimize_Spline reducedMinKnots:2 reduce_method:1)
- convertToSplineShape $
- $.pivot = $.center
- gc lite:true
- )
- EnableSceneRedraw()
- )
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement