Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a sketch Error, vb 1

Status
Not open for further replies.

Twullf

Mechanical
Jan 24, 2012
196
I have a piece of code that creates a sketch with no problem and it works as follows:

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

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
 
Replies continue below

Recommended for you

Are you sure that the objects you are passing in are a DatumPlane object and a Point3d object? If they are not, you will get such an error. After you assign the datum plane and point variables, add some code such as:
Code:
msgbox(myDatumVariable.GetType.ToString)
msgbox(myPointVariable.GetType.ToString)
just to see if the type of object matches what you expect.

 
I am not having much success is finding the difference between a point and a point3D. Both seem to be defined by the three major axis, both thus are 3 dimensional.

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.
 
I would try:
Code:
myPoint3d = pointObject.Coordinates

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.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor