Hi,
Inventor 2022
API VB.NET VisualStudio
i try to Get Point from Method: Inventor 2022 Help | MeasureTools.GetMinimumDistance Method | Autodesk
How to get the Point from https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=NameValueMap
Vector of minimum distance - Manufacturing DevBlog (typepad.com)
Code:
Public Sub CommandFunctionfweButton_()
Dim oPartDoc As PartDocument = g_inventorApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oTO As TransientObjects = g_inventorApplication.TransientObjects
Dim oTG As TransientGeometry = g_inventorApplication.TransientGeometry
Dim oBRep As TransientBRep = g_inventorApplication.TransientBRep
Dim oSketch3D As Sketch3D = oCompDef.Sketches3D.Item(1)
Dim oSketchSpline As SketchSpline3D = oSketch3D.SketchSplines3D.Item(1)
Dim oBSpline3D As BSplineCurve = oSketchSpline.Geometry
Dim oWorkSurface As WorkSurface = oCompDef.WorkSurfaces.Item(1)
Dim oSurfaceBody As SurfaceBody = oWorkSurface._SurfaceBody
Dim oSurface As Face = oSurfaceBody.Faces.Item(1)
Dim oPoint As Point
Dim oContext As NameValueMap = g_inventorApplication.TransientObjects.CreateNameValueMap
oContext.Add("", oPoint)
Dim oInterSectionSurface As Double = g_inventorApplication.MeasureTools.GetMinimumDistance(oBSpline3D, oSurface,,, oContext)
Dim oPointX As Point = oContext.Item("ClosestPointOne")
Dim oObjCollPoints As ObjectCollection = oTO.CreateObjectCollection
oObjCollPoints.Add(oPointX)
End Sub
Thanks for any Suggestion
Solved! Go to Solution.
Hi,
Inventor 2022
API VB.NET VisualStudio
i try to Get Point from Method: Inventor 2022 Help | MeasureTools.GetMinimumDistance Method | Autodesk
How to get the Point from https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=NameValueMap
Vector of minimum distance - Manufacturing DevBlog (typepad.com)
Code:
Public Sub CommandFunctionfweButton_()
Dim oPartDoc As PartDocument = g_inventorApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oTO As TransientObjects = g_inventorApplication.TransientObjects
Dim oTG As TransientGeometry = g_inventorApplication.TransientGeometry
Dim oBRep As TransientBRep = g_inventorApplication.TransientBRep
Dim oSketch3D As Sketch3D = oCompDef.Sketches3D.Item(1)
Dim oSketchSpline As SketchSpline3D = oSketch3D.SketchSplines3D.Item(1)
Dim oBSpline3D As BSplineCurve = oSketchSpline.Geometry
Dim oWorkSurface As WorkSurface = oCompDef.WorkSurfaces.Item(1)
Dim oSurfaceBody As SurfaceBody = oWorkSurface._SurfaceBody
Dim oSurface As Face = oSurfaceBody.Faces.Item(1)
Dim oPoint As Point
Dim oContext As NameValueMap = g_inventorApplication.TransientObjects.CreateNameValueMap
oContext.Add("", oPoint)
Dim oInterSectionSurface As Double = g_inventorApplication.MeasureTools.GetMinimumDistance(oBSpline3D, oSurface,,, oContext)
Dim oPointX As Point = oContext.Item("ClosestPointOne")
Dim oObjCollPoints As ObjectCollection = oTO.CreateObjectCollection
oObjCollPoints.Add(oPointX)
End Sub
Thanks for any Suggestion
Solved! Go to Solution.
Solved by YuhanZhang. Go to Solution.
Solved by Michael.Navara. Go to Solution.
Solved by Michael.Navara. Go to Solution.
In my historical implementation I found undocumented context item "IntersectionPoint", but it doesn't work anymore.
You need to use TransientGeometry.CurveSurfaceIntersection Method in this case
Public Sub CommandFunctionfweButton2()
Dim g_inventorApplication As Inventor.Application = ThisApplication
Dim oPartDoc As PartDocument = g_inventorApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oTO As TransientObjects = g_inventorApplication.TransientObjects
Dim oTG As TransientGeometry = g_inventorApplication.TransientGeometry
Dim oBRep As TransientBRep = g_inventorApplication.TransientBRep
Dim oSketch3D As Sketch3D = oCompDef.Sketches3D.Item(1)
Dim oSketchSpline As SketchSpline3D = oSketch3D.SketchSplines3D.Item(1)
Dim oBSpline3D As BSplineCurve = oSketchSpline.Geometry
Dim oWorkSurface As WorkSurface = oCompDef.WorkSurfaces.Item(1)
Dim oSurfaceBody As SurfaceBody = oWorkSurface.SurfaceBodies(1)
Dim oSurface As Face = oSurfaceBody.Faces(1)
Dim oBSplineSurface As BSplineSurface = oSurface.Geometry
Dim curveSurfaceIntersections As ObjectsEnumerator = oTG.CurveSurfaceIntersection(oBSpline3D, oBSplineSurface)
Dim oPoint As Point = curveSurfaceIntersections(1)
Logger.Debug("[{0:N2}, {1:N2}, {2:N2}]", oPoint.X, oPoint.Y, oPoint.Z)
End Sub
In my historical implementation I found undocumented context item "IntersectionPoint", but it doesn't work anymore.
You need to use TransientGeometry.CurveSurfaceIntersection Method in this case
Public Sub CommandFunctionfweButton2()
Dim g_inventorApplication As Inventor.Application = ThisApplication
Dim oPartDoc As PartDocument = g_inventorApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oTO As TransientObjects = g_inventorApplication.TransientObjects
Dim oTG As TransientGeometry = g_inventorApplication.TransientGeometry
Dim oBRep As TransientBRep = g_inventorApplication.TransientBRep
Dim oSketch3D As Sketch3D = oCompDef.Sketches3D.Item(1)
Dim oSketchSpline As SketchSpline3D = oSketch3D.SketchSplines3D.Item(1)
Dim oBSpline3D As BSplineCurve = oSketchSpline.Geometry
Dim oWorkSurface As WorkSurface = oCompDef.WorkSurfaces.Item(1)
Dim oSurfaceBody As SurfaceBody = oWorkSurface.SurfaceBodies(1)
Dim oSurface As Face = oSurfaceBody.Faces(1)
Dim oBSplineSurface As BSplineSurface = oSurface.Geometry
Dim curveSurfaceIntersections As ObjectsEnumerator = oTG.CurveSurfaceIntersection(oBSpline3D, oBSplineSurface)
Dim oPoint As Point = curveSurfaceIntersections(1)
Logger.Debug("[{0:N2}, {1:N2}, {2:N2}]", oPoint.X, oPoint.Y, oPoint.Z)
End Sub
Hi @Michael.Navara ,
Thanks for Answer.
but,No!
i know how to make a Intersection from Curve 🙂
I Want to Know, how to get this information from This Method: MeasureTools.GetMinimumDistance
Inventor 2022 Help | MeasureTools.GetMinimumDistance Method | Autodesk
Because, is probably possible.
@adam.nagy made a Post in DevBlog about This : Vector of minimum distance - Manufacturing DevBlog (typepad.com)
And i want to know, how to do this in this Case.
If this is Possible.
This was only a Example.
For me, this Methode (MeasureTools.GetMinimumDistance) is a very interesting Methode.
because, is possible to get information, if for example a Surface has intersection with other Surface or Curve.
And this i can do.
But i want to get The Point with this Methode.
With Context, from NameValueMap
Hi @Michael.Navara ,
Thanks for Answer.
but,No!
i know how to make a Intersection from Curve 🙂
I Want to Know, how to get this information from This Method: MeasureTools.GetMinimumDistance
Inventor 2022 Help | MeasureTools.GetMinimumDistance Method | Autodesk
Because, is probably possible.
@adam.nagy made a Post in DevBlog about This : Vector of minimum distance - Manufacturing DevBlog (typepad.com)
And i want to know, how to do this in this Case.
If this is Possible.
This was only a Example.
For me, this Methode (MeasureTools.GetMinimumDistance) is a very interesting Methode.
because, is possible to get information, if for example a Surface has intersection with other Surface or Curve.
And this i can do.
But i want to get The Point with this Methode.
With Context, from NameValueMap
In my opinion it is not possible. As I mentioned above, there was "IntersectionPoint" value in context name value map, but it was removed or it is not available in this case. In general you can get more then one intersection point. You can create your own method which returns intersection point, but you need to decide which one if more then one was found.
In my opinion it is not possible. As I mentioned above, there was "IntersectionPoint" value in context name value map, but it was removed or it is not available in this case. In general you can get more then one intersection point. You can create your own method which returns intersection point, but you need to decide which one if more then one was found.
Hi @Michael.Navara ,
Not exactly, because look, this is the example from DevBlog, and it Works:
Code:
Dim oAsmDoc As AssemblyDocument = g_inventorApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
Dim oTO As TransientObjects = g_inventorApplication.TransientObjects
Dim oTG As TransientGeometry = g_inventorApplication.TransientGeometry
Dim oBRep As TransientBRep = g_inventorApplication.TransientBRep
Dim occs As ComponentOccurrences = oAsmDoc.ComponentDefinition.Occurrences
Dim context As NameValueMap
Dim dist As Double
dist = g_inventorApplication.MeasureTools.GetMinimumDistance(occs(1), occs(2), , , context)
' Let's add the points as work points
Dim wps As WorkPoints = oAsmDoc.ComponentDefinition.WorkPoints
Call wps.AddFixed(context.Item("ClosestPointOne"))
Call wps.AddFixed(context.Item("ClosestPointTwo"))
End Sub
Assembly and Parts in Attachment.
UPDATE:
So it works also with Parts.
Code:
Public Sub CommandFunctionfweButton_45()
Dim oPartDoc As PartDocument = g_inventorApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oTO As TransientObjects = g_inventorApplication.TransientObjects
Dim oTG As TransientGeometry = g_inventorApplication.TransientGeometry
Dim oBRep As TransientBRep = g_inventorApplication.TransientBRep
Dim oBody_01 As SurfaceBody = oCompDef.SurfaceBodies.Item(1)
Dim oFace_01 As Face = oBody_01.Faces.Item(1)
Dim oBody_02 As SurfaceBody = oCompDef.SurfaceBodies.Item(2)
Dim oFace_02 As Face = oBody_02.Faces.Item(2)
Dim context As NameValueMap
Dim dist As Double = g_inventorApplication.MeasureTools.GetMinimumDistance(oFace_01, oFace_02, , , context)
' Let's add the points as work points
Dim wps As WorkPoints = oCompDef.WorkPoints
Call wps.AddFixed(context.Item("ClosestPointOne"))
Call wps.AddFixed(context.Item("ClosestPointTwo"))
End Sub
Maybe, it works not like expect, or not with all Objects, or something like this
Hi @Michael.Navara ,
Not exactly, because look, this is the example from DevBlog, and it Works:
Code:
Dim oAsmDoc As AssemblyDocument = g_inventorApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition
Dim oTO As TransientObjects = g_inventorApplication.TransientObjects
Dim oTG As TransientGeometry = g_inventorApplication.TransientGeometry
Dim oBRep As TransientBRep = g_inventorApplication.TransientBRep
Dim occs As ComponentOccurrences = oAsmDoc.ComponentDefinition.Occurrences
Dim context As NameValueMap
Dim dist As Double
dist = g_inventorApplication.MeasureTools.GetMinimumDistance(occs(1), occs(2), , , context)
' Let's add the points as work points
Dim wps As WorkPoints = oAsmDoc.ComponentDefinition.WorkPoints
Call wps.AddFixed(context.Item("ClosestPointOne"))
Call wps.AddFixed(context.Item("ClosestPointTwo"))
End Sub
Assembly and Parts in Attachment.
UPDATE:
So it works also with Parts.
Code:
Public Sub CommandFunctionfweButton_45()
Dim oPartDoc As PartDocument = g_inventorApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oTO As TransientObjects = g_inventorApplication.TransientObjects
Dim oTG As TransientGeometry = g_inventorApplication.TransientGeometry
Dim oBRep As TransientBRep = g_inventorApplication.TransientBRep
Dim oBody_01 As SurfaceBody = oCompDef.SurfaceBodies.Item(1)
Dim oFace_01 As Face = oBody_01.Faces.Item(1)
Dim oBody_02 As SurfaceBody = oCompDef.SurfaceBodies.Item(2)
Dim oFace_02 As Face = oBody_02.Faces.Item(2)
Dim context As NameValueMap
Dim dist As Double = g_inventorApplication.MeasureTools.GetMinimumDistance(oFace_01, oFace_02, , , context)
' Let's add the points as work points
Dim wps As WorkPoints = oCompDef.WorkPoints
Call wps.AddFixed(context.Item("ClosestPointOne"))
Call wps.AddFixed(context.Item("ClosestPointTwo"))
End Sub
Maybe, it works not like expect, or not with all Objects, or something like this
Hi,
as i see it works not with BSplineSurface.
It works only with Planar Faces, Corect my if im wrong.
This is a Example:
Model : Part F and Part D
Code:
Public Sub CommandFunctionfweButton_48()
Dim oPartDoc As PartDocument = g_inventorApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oTO As TransientObjects = g_inventorApplication.TransientObjects
Dim oTG As TransientGeometry = g_inventorApplication.TransientGeometry
Dim oBRep As TransientBRep = g_inventorApplication.TransientBRep
Dim oSketch3D As Sketch3D = oCompDef.Sketches3D.Item(1)
Dim oSketchSpline As SketchSpline3D = oSketch3D.SketchSplines3D.Item(1)
Dim oBSpline3D As BSplineCurve = oSketchSpline.Geometry
Dim oWorkSurface As WorkSurface = oCompDef.WorkSurfaces.Item(1)
Dim oSurfaceBody As SurfaceBody = oWorkSurface._SurfaceBody
Dim oSurface As Face = oSurfaceBody.Faces.Item(1)
Dim oPlane As Object = oSurface.Geometry
Dim context As NameValueMap
Dim dist As Double = g_inventorApplication.MeasureTools.GetMinimumDistance(oBSpline3D, oSurface, , , context)
Dim oSketch As Sketch3D = oCompDef.Sketches3D.Add
Dim oPoint_01 As Point = context.Item("ClosestPointOne")
Dim oPoint_02 As Point = context.Item("ClosestPointTwo")
Dim oSketchPoint_01 As SketchPoint3D = oSketch.SketchPoints3D.Add(oPoint_01)
Dim oSketchPoint_02 As SketchPoint3D = oSketch.SketchPoints3D.Add(oPoint_02)
End Sub
it Works with
Part F - Planar Face
but not Work with
Part D - BSplineSurface
Part F - Ok
PartD - Unknow Error
So, the Question, is Possible to do this in Other Way with BSplineSurface ?
i mean with Methode MeasureTools.GetMinimumDistance
The Thing is i want to Automate some Proces, to Cut Some Surfaces (BSplineSurfaces),
and then to Cut Splines,
And Then to Create Closed Profiles,
and Then Create some New Surfaces.
Actualy, ok This what you say @Michael.Navara with (TransientGeometry.CurveSurfaceIntersection Method) is enough, and i can leave this so.
Thanks
Hi,
as i see it works not with BSplineSurface.
It works only with Planar Faces, Corect my if im wrong.
This is a Example:
Model : Part F and Part D
Code:
Public Sub CommandFunctionfweButton_48()
Dim oPartDoc As PartDocument = g_inventorApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oTO As TransientObjects = g_inventorApplication.TransientObjects
Dim oTG As TransientGeometry = g_inventorApplication.TransientGeometry
Dim oBRep As TransientBRep = g_inventorApplication.TransientBRep
Dim oSketch3D As Sketch3D = oCompDef.Sketches3D.Item(1)
Dim oSketchSpline As SketchSpline3D = oSketch3D.SketchSplines3D.Item(1)
Dim oBSpline3D As BSplineCurve = oSketchSpline.Geometry
Dim oWorkSurface As WorkSurface = oCompDef.WorkSurfaces.Item(1)
Dim oSurfaceBody As SurfaceBody = oWorkSurface._SurfaceBody
Dim oSurface As Face = oSurfaceBody.Faces.Item(1)
Dim oPlane As Object = oSurface.Geometry
Dim context As NameValueMap
Dim dist As Double = g_inventorApplication.MeasureTools.GetMinimumDistance(oBSpline3D, oSurface, , , context)
Dim oSketch As Sketch3D = oCompDef.Sketches3D.Add
Dim oPoint_01 As Point = context.Item("ClosestPointOne")
Dim oPoint_02 As Point = context.Item("ClosestPointTwo")
Dim oSketchPoint_01 As SketchPoint3D = oSketch.SketchPoints3D.Add(oPoint_01)
Dim oSketchPoint_02 As SketchPoint3D = oSketch.SketchPoints3D.Add(oPoint_02)
End Sub
it Works with
Part F - Planar Face
but not Work with
Part D - BSplineSurface
Part F - Ok
PartD - Unknow Error
So, the Question, is Possible to do this in Other Way with BSplineSurface ?
i mean with Methode MeasureTools.GetMinimumDistance
The Thing is i want to Automate some Proces, to Cut Some Surfaces (BSplineSurfaces),
and then to Cut Splines,
And Then to Create Closed Profiles,
and Then Create some New Surfaces.
Actualy, ok This what you say @Michael.Navara with (TransientGeometry.CurveSurfaceIntersection Method) is enough, and i can leave this so.
Thanks
Hi @florian_wenzel , I think @Michael.Navara already answered this question. When you use the GetMinimumDistance for two entities, if the return value is 0, and the Context returns the "IntersectionFound" = True, that means the two entities are intersected, and in this case the method won't return the intersection points(the "ClosestPointOne" and "ClosestPointTwo" etc. won't be applicable, so you need to check whether the "IntersectionFound" = True before querying the closest point info from the Context), and then you need to make use of TransientGeometry.SurfaceSurfaceIntersection/CurveSurfaceIntersection/CurveCurveIntersection to get the intersection points/curves of the two entities.
Hope above clears.
Hi @florian_wenzel , I think @Michael.Navara already answered this question. When you use the GetMinimumDistance for two entities, if the return value is 0, and the Context returns the "IntersectionFound" = True, that means the two entities are intersected, and in this case the method won't return the intersection points(the "ClosestPointOne" and "ClosestPointTwo" etc. won't be applicable, so you need to check whether the "IntersectionFound" = True before querying the closest point info from the Context), and then you need to make use of TransientGeometry.SurfaceSurfaceIntersection/CurveSurfaceIntersection/CurveCurveIntersection to get the intersection points/curves of the two entities.
Hope above clears.
Hi @YuhanZhang ,
Thanks for Answer.
Yes i Understand.
Only, when the 2 Entity will not has Intersection, than it will be able to get :
"ClosestPointOne" and "ClosestPointTwo"
Thanks.
Hi @YuhanZhang ,
Thanks for Answer.
Yes i Understand.
Only, when the 2 Entity will not has Intersection, than it will be able to get :
"ClosestPointOne" and "ClosestPointTwo"
Thanks.
Yes, when two entities are intersected, they may have multiple intersection points or curves, currently we don't return the intersection points/curves from the GetMinimumDistance method, and you need to use the methods under TransientGeometry to get the intersection points/curves. I think the methods should work for both planar and non-planar surfaces, if you see any problem with the methods please let me know.
Yes, when two entities are intersected, they may have multiple intersection points or curves, currently we don't return the intersection points/curves from the GetMinimumDistance method, and you need to use the methods under TransientGeometry to get the intersection points/curves. I think the methods should work for both planar and non-planar surfaces, if you see any problem with the methods please let me know.
Can't find what you're looking for? Ask the community or share your knowledge.