Creating a sketch Error, vb
Creating a sketch Error, vb
(OP)
I have a piece of code that creates a sketch with no problem and it works as follows:
I am wanting to put it in a subroutine in a larger program which will pass the values of point1 and datumplane1. Seems simple enough, I pass the point and datumplane as a reference and comment out the two lines dimensioning and picking values in space. But I keep getting the error:
Overload resolution failed because no accessible 'SetValue' can be called with these arguments.
My mind is boggling as to why this works fine alone then not when I put it in the subroutine, I am literally making no other changes.
Any help would be appreciated
CODE
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
' ----------------------------------------------
' Menu: Insert->Sketch...
' ----------------------------------------------
Dim nullSketch As Sketch = Nothing
Dim unit1 As Unit = CType(workPart.UnitCollection.FindObject("MilliMeter"), Unit)
Dim sketchInPlaceBuilder1 As SketchInPlaceBuilder
sketchInPlaceBuilder1 = workPart.Sketches.CreateNewSketchInPlaceBuilder(nullSketch)
Dim section1 As Section
section1 = workPart.Sections.CreateSection(0.02413, 0.0254, 0.5)
Dim section2 As Section
section2 = workPart.Sections.CreateSection(0.02413, 0.0254, 0.5)
Dim sketchAlongPathBuilder1 As SketchAlongPathBuilder
sketchAlongPathBuilder1 = workPart.Sketches.CreateSketchAlongPathBuilder(nullSketch)
sketchInPlaceBuilder1.PlaneOption = Sketch.PlaneOption.ExistingPlane
sketchAlongPathBuilder1.PlaneLocation.Expression.RightHandSide = "0"
Dim datumPlane1 As DatumPlane = CType(workPart.Datums.FindObject("DATUM_PLANE(2)"), DatumPlane)
Dim point1 As Point3d = New Point3d(-26.9250911787209, -9.27932082491816, 6134.90591187597)
sketchInPlaceBuilder1.PlaneOrFace.SetValue(datumPlane1, workPart.ModelingViews.WorkView, point1)
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Create Sketch")
Dim nXObject1 As NXObject
nXObject1 = sketchInPlaceBuilder1.Commit()
Dim sketch1 As Sketch = CType(nXObject1, Sketch)
Dim feature1 As Features.Feature
feature1 = sketch1.Feature
sketch1.Activate(Sketch.ViewReorient.False)
sketchInPlaceBuilder1.Destroy()
sketchAlongPathBuilder1.Destroy()
section1.Destroy()
theSession.ActiveSketch.Deactivate(Sketch.ViewReorient.False, Sketch.UpdateLevel.Model)
End Sub
End Module
Imports System
Imports NXOpen
Module NXJournal
Sub Main
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
' ----------------------------------------------
' Menu: Insert->Sketch...
' ----------------------------------------------
Dim nullSketch As Sketch = Nothing
Dim unit1 As Unit = CType(workPart.UnitCollection.FindObject("MilliMeter"), Unit)
Dim sketchInPlaceBuilder1 As SketchInPlaceBuilder
sketchInPlaceBuilder1 = workPart.Sketches.CreateNewSketchInPlaceBuilder(nullSketch)
Dim section1 As Section
section1 = workPart.Sections.CreateSection(0.02413, 0.0254, 0.5)
Dim section2 As Section
section2 = workPart.Sections.CreateSection(0.02413, 0.0254, 0.5)
Dim sketchAlongPathBuilder1 As SketchAlongPathBuilder
sketchAlongPathBuilder1 = workPart.Sketches.CreateSketchAlongPathBuilder(nullSketch)
sketchInPlaceBuilder1.PlaneOption = Sketch.PlaneOption.ExistingPlane
sketchAlongPathBuilder1.PlaneLocation.Expression.RightHandSide = "0"
Dim datumPlane1 As DatumPlane = CType(workPart.Datums.FindObject("DATUM_PLANE(2)"), DatumPlane)
Dim point1 As Point3d = New Point3d(-26.9250911787209, -9.27932082491816, 6134.90591187597)
sketchInPlaceBuilder1.PlaneOrFace.SetValue(datumPlane1, workPart.ModelingViews.WorkView, point1)
Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Create Sketch")
Dim nXObject1 As NXObject
nXObject1 = sketchInPlaceBuilder1.Commit()
Dim sketch1 As Sketch = CType(nXObject1, Sketch)
Dim feature1 As Features.Feature
feature1 = sketch1.Feature
sketch1.Activate(Sketch.ViewReorient.False)
sketchInPlaceBuilder1.Destroy()
sketchAlongPathBuilder1.Destroy()
section1.Destroy()
theSession.ActiveSketch.Deactivate(Sketch.ViewReorient.False, Sketch.UpdateLevel.Model)
End Sub
End Module
I am wanting to put it in a subroutine in a larger program which will pass the values of point1 and datumplane1. Seems simple enough, I pass the point and datumplane as a reference and comment out the two lines dimensioning and picking values in space. But I keep getting the error:
Overload resolution failed because no accessible 'SetValue' can be called with these arguments.
CODE
sketchInPlaceBuilder1.PlaneOrFace.SetValue(datumPlane1, workPart.ModelingViews.WorkView, point1)
My mind is boggling as to why this works fine alone then not when I put it in the subroutine, I am literally making no other changes.
Any help would be appreciated





RE: Creating a sketch Error, vb
CODE
msgbox(myPointVariable.GetType.ToString)
www.nxjournaling.com
RE: Creating a sketch Error, vb
That was/is probably the problem, though now I need to somehow define the 3D point when I currently am working with a regular point. NXOpen help is not being much help in the area.
RE: Creating a sketch Error, vb
CODE
The point object and point3d object have different internal structure; the method you called is defined to work with only point3d objects and was therefore complaining that you passed in the wrong object.
www.nxjournaling.com