Hi
I hope you don't mind if I ask you one question about freefrom curves in KernalCAD 3.2.I've found I need a little more control over the shape of the curve. This seems to be provided in your ArcSpline curve. The attached code implements this successfully but I have a problem in setting the spline curvature. It may be that I have the logic wrong. Would you be able to offer any advice on this? I've indicated the error I'm getting in the attached code.
'----------------------------------------------------------------------
' Spline Test #3 - arcspline curve with modified curvature
'----------------------------------------------------------------------
Private Sub mnuSpline3_Click()
Dim iGenerator As IDIObjGenerator ' object generator
Dim iUnknown As Variant '
Dim iUnknLineSection As Variant '
Dim iCurveFF As ICurveFreeForm '
Dim iCurveAS As IArcSpline3DCurve '
Dim iArr3D As IArray3D '
Dim iArrayNM As IArrayNum '
Dim iLinesect As ILineSection_KC '
Dim iSectLine As ISection '
Dim iMod As iModel '
Dim iMod2 As IModel2 '
Dim i As Long '
' 1. Load some test points
Load_Points
' 2. Create a new freeformcurve object
Set iGenerator = CreateObject("KERNELCAD.DIObjGenerator.1")
Set iUnknown = iGenerator.Create(EObjectType.eObjTypeArcSplineCurve)
Set iCurveFF = iUnknown
Set iArr3D = iCurveFF.GetData
' 3. Load the data points
iArr3D.SetCount 8
For i = 0 To 7
iArr3D.Set i, Xp(i), Yp(i), Zp(i)
Next i
' 4. Wrap the curve into a section to add to the model
Set iUnknLineSection = iGenerator.Create(EObjectType.eObjTypeLineSection)
Set iLinesect = iUnknLineSection
iLinesect.SetCurve iCurveFF
' 5. Add the section to the model
Set iSectLine = iLinesect
Set iMod = KernelCAD1.GetModel()
Set iMod2 = iMod
iMod2.Add iSectLine
iSectLine.SetName "Spline2"
' 6. Get and adjust the spline curvature
Dim Num1 As Long
Dim dV1 As Double
Dim dV2 As Double
' Use IArrayNum obtained with IArcSpline3DCurve.GetCurvatureArray to modify curvature of arcs.
' By default curvature is zero, which represents a straight line.
Set iCurveAS = iUnknown
Set iArrayNM = iCurveAS.GetCurvatureArray
Num1 = iArrayNM.GetCount ' returns a value of 8
' Get some values (should all be zero)
dV1 = iArrayNM.Get(1)
dV2 = iArrayNM.Get(2)
' Update some values of curvature - this causes an error
iArrayNM.Set 2, 0.5 ' generates an error - Argument Not Optional
iArrayNM.Set 3, 0.5
' 7. Update the display
KernelCAD1.UpdateSurface
mnuReset_Click
End Sub
'----------------------------------------------------------------------
Issue with Arc Curve Spline
Re: Issue with Arc Curve Spline
Hi John
It can be that you are trying to set too high curvature. Curvature is 1/radius, as you know. So normally you set all curvatures to zero, set the points as required and then set the needed curvatures making sure it is not higher than 2/(distance between the ends)
Gerard
It can be that you are trying to set too high curvature. Curvature is 1/radius, as you know. So normally you set all curvatures to zero, set the points as required and then set the needed curvatures making sure it is not higher than 2/(distance between the ends)
Gerard
Re: Issue with Arc Curve Spline
Thank you, Gerard
It explains it. I got it working
John
It explains it. I got it working
John