×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Creating a sketch Error, vb

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:

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

RE: Creating a sketch Error, vb

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.

www.nxjournaling.com

RE: Creating a sketch Error, vb

(OP)
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.

RE: Creating a sketch Error, vb

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.

www.nxjournaling.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources