- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
the attached file contains a reduced example.
A sketch with some random geometry:
An arc, a line and a bisected spline.
It also contains one rule:
For each entity, the parameter range is determined by Geometry.Evaluator.GetParamExtents(uMin, uMax). Then, three points are calculated: one at the start, one at the end, one in the middle, using Geometry.Evaluator.GetPointAtParam.
A message box displays the results for each entity.
Expected behavior would be for the output to match the apparent start point in the sketch.
Actual behavior is that lines are evaluated as expected, splines are hit-and-miss and arcs are completely broken. Others not tested.
Current workaround is to write my own evaluator based on the known geometry properties for the arc case, and for the spline case to pray.
I am not interested in these particular points. I need the evaluator to function generally.
Please advise/fix
Regards,
Samuel
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This is little bit modified version of your code. It works well.
- I don't check type of entity and I directly try to get Evaluator from sketchEntity (Using LateBinding in VB.NET).
- I change mid point calculation.
- I change building of final message
Sub Main
Dim part As PartDocument = ThisDoc.Document
Dim sk As PlanarSketch = part.ComponentDefinition.Sketches("Test Sketch")
For Each sketchEntity As SketchEntity In sk.SketchEntities
Dim evaluator As Curve2dEvaluator = GetEvaluator(SketchEntity)
If evaluator Is Nothing Then Continue For
Dim periodicity As Double() = {}
Dim isSingular As Boolean
Dim unboundedParameter As Boolean
evaluator.GetParamAnomaly(periodicity, isSingular, unboundedParameter)
Dim endPoint As Double() = {}
Dim startPoint As Double() = {}
evaluator.GetEndPoints(startPoint, endPoint)
Dim minParam As Double
Dim maxParam As Double
Dim midParam As Double
Dim midPoint As Double() = {}
evaluator.GetParamExtents(minParam, maxParam)
midParam = minParam + (maxParam - minParam) / 2
evaluator.GetPointAtParam(New Double() {midParam }, midPoint)
Dim msg As String = String.Format( _
"Curve Type: {0}" & vbCrLf & _
"Start Point: [{1:N3},{2:N3}]" & vbCrLf & _
"End point: [{3:N3}, {4:N3}]" & vbCrLf & _
"Mid Point: [{5:N3}, {6:N3}]" & vbCrLf & _
"Param anomaly:" & vbCrLf & _
" - periodicity: [{7:N3}, {8:N3}]" & vbCrLf & _
" - Is sinhgular: {9}" & vbCrLf & _
" - Unbounded parameter: {10}",
SketchEntity.Type,
startPoint(0), startPoint(1),
endPoint(0), endPoint(1),
midPoint(0), midPoint(1),
periodicity(0), periodicity(1),
isSingular,
unboundedParameter
)
MsgBox(msg, Title := "Curve Info")
Next
End Sub
Function GetEvaluator(sketchEntity As SketchEntity) As Curve2dEvaluator
Try
Return sketchEntity.Geometry.Evaluator
Catch
Return Nothing
End Try
End Function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
thank you for taking the time to help me with my problem.
Beside the cosmetic changes, about which I think reasonable minds may differ, you made a change to the way that that the parameter variable is allocated. Whereas I allocated the memory at the top of the function, you did so in line with the function call.
(Works)
evaluator.GetPointAtParam(New Double() {midParam }, midPoint)
vs (Works unreliably)
Dim u(1) as Double
u(0)=midParam
evaluator.GetPointAtParam(u, midPoint)
This seems to be a functioning workaround. Thank you for providing this solution.
If anyone from Autodesk is around, I would like to know if this is indeed bugged, or if I have somehow missed an important point about memory allocation in VBA.