Notifications
Clear all

[Closed] Converting spline to mesh problem

Hi,

Im trying to create a mesh from a simple shape, but fail when I try to convert the spline to mesh.
When I do the same steps by hand, the conversion works. Can anyone point me in the right direction?

(
	fn createBaseLine baseLength =
	(
		baseLine = splineshape()
		addNewSpline baseLine
		addKnot baseLine 1 #corner #line [0, 0, 0]
		addKnot baseLine 1 #corner #line [baseLength * 0.5, 0, 0]
		updateShape baseLine
		baseLine
	)
	
	fn editSpinner hwnd val = 
	(
		WM_CHAR = 0x0102
		VK_RETURN = 0x000D

		UIAccessor.setWindowText hwnd (units.formatValue val)
		windows.sendMessage hwnd WM_CHAR VK_RETURN 0
	)
	
	fn findFilletSpinnerHwnd = 
	(
		children = windows.getChildrenHWND #max
		hwndIndex = for i = 1 to children.count where children[i][5] == "Edit Vertex" do exit with i
		children[hwndIndex + 4][1]
	)
	
	fn createMesh baseLength cornerRadius =
	(	
		baseLine = createBaseLine baseLength
		rotBaseLine = copy baseLine
		rotate rotBaseLine (eulerAngles 0 -60 0)
		addAndWeld baseLine rotBaseLine 1
		setKnotSelection baseLine 1 #(2)
		
		addModifier baseLine (fillet_chamfer())
		select baseLine
		
		spinnerHwnd = findFilletSpinnerHwnd()
		editSpinner spinnerHwnd cornerRadius
		collapsestack baseLine
			
		
		rightSide = copy baseLine transform:(matrix3 [-1,0,0] [0,1,0] [0,0,1] [baseLength,0,0])
		topSide = copy baseLine 
		rotate topSide (eulerAngles 0 120 0)
		move topSide [baseLength * 0.5, 0, baseLength * sin 60]
		
		setCommandPanelTaskMode mode:#modify
			
		addAndWeld baseLine topSide 1
		addAndWeld baseLine rightSide 1
		
		deleteknot baseLine 1 11
		deleteknot baseLine 1 6
		deleteknot baseLine 1 1
			
		updateShape baseLine
	)
	
	rollout rolMainRollout "Mesh"
	(
		spinner spnSideLength "Side length" type:#worldUnits range:[0,10000,90] 
		spinner spnCornerRadius "Corner radius" type:#worldUnits range:[0,90, 4]
		button btnCreate "Create" align:#right
		
		on btnCreate pressed do
			createMesh spnSideLength.value spnCornerRadius.value
	)
	
	createDialog rolMainRollout 
)
1 Reply

This works though:

fn createMesh2 baseLength cornerRadius = 
	(
		baseLength *= 2
		baseLine = createBaseLine baseLength
		baseLine.pivot = [baseLength * 0.5,0,0]
		rightSide = copy baseLine
		rotate rightSide (eulerAngles 0 60 0)
		baseLine.pivot = [0,0,0]
		leftSide = copy baseLine
		rotate leftSide (eulerAngles 0 -60 0)
		
		addAndWeld baseLine rightSide 1 
		addAndWeld baseLine leftSide 1
		setKnotSelection baseLine 1 (#{1..(numKnots baseLine)} as array)
		addModifier baseLine (fillet_chamfer())
		select baseLine
		
		spinnerHwnd = findFilletSpinnerHwnd()
		editSpinner spinnerHwnd cornerRadius
			
		convertTomesh baseLine
	)