How to get co-ordinate value (X and Y) of drafting curve

Hello,

I have created one block. After that one sketch on top surface which contains one line. then i have created baseview of that model in drawing.
So now I want the co-ordinates of the single line which is draftingcurve in drawing.
But i am not able to get the X value in this case.

So how to get the X value ?

I have used below code :


Option Strict Off
Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.UF
Imports NXOpen.Utilities
Imports NXOpen.Drafting

Module module1

Dim theSession As Session
Dim workPart As Part
Dim displayPart As Part
Dim ufs As UFSession
Dim theUI As UI
Dim dwgShtBld As Drawings.DrawingSheetBuilder
Dim ufsession As UFSession

Sub Main()

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim theSection As Section = workPart.Sections.CreateSection()
Dim point As Double

Dim baseView1 As Drawings.BaseView = CType(workPart.DraftingViews.FindObject("Right@2"), Drawings.BaseView)
MsgBox(baseView1.Name)
baseView1.Expand()
Dim draftingBody1 As Drawings.DraftingBody = CType(workPart.DraftingViews.FindObject("Right@2").DraftingBodies.FindObject(" 0"), Drawings.DraftingBody)

Dim Curves As CurveCollection = workPart.Curves

For Each draftingCurve1 As Drawings.DraftingCurve In draftingBody1.DraftingCurves

MsgBox(draftingCurve1.Name)
MsgBox(CStr(draftingCurve1.NameLocation.Y))

Next

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

End Function
End Module

Drafting curves don't seem to provide an easy means of getting the endpoint coordinates. The Y coordinate that you have is for the name display, it isn't necessarily a point on the line.

I'm curious why you would need the drafting curve coordinates? Would you want the drawing sheet coordinates of the line or the model space coordinates?

Yes i want the drawing sheet co-ordinates of the line.

Bhavik S.

Expanding on your code, here is a quick & dirty example of how to get the parent of the drafting curve.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()

Dim lw As ListingWindow = theSession.ListingWindow

Sub Main()

Dim workPart As Part = theSession.Parts.Work
lw.open
Dim baseView1 As Drawings.BaseView = CType(workPart.DraftingViews.FindObject("Top@1"), Drawings.BaseView)
MsgBox(baseView1.Name)
Dim draftingBody1 As Drawings.DraftingBody = CType(workPart.DraftingViews.FindObject("Top@1").DraftingBodies.FindObject(" 0"), Drawings.DraftingBody)

Dim Curves As CurveCollection = workPart.Curves

For Each draftingCurve1 As Drawings.DraftingCurve In draftingBody1.DraftingCurves

MsgBox(draftingCurve1.Name)

Dim parentCount As Integer
Dim parentTags() As Tag
theUfSession.Draw.AskDraftingCurveParents(draftingCurve1.tag, parentCount, parentTags)

lw.writeline("parent count: " & parentCount.ToString)

For Each tempTag As Tag In parentTags
Dim theTaggedObj As TaggedObject = Utilities.NXObjectManager.Get(tempTag)
lw.writeline(" object type: " & theTaggedObj.GetType.ToString)
If TypeOf (theTaggedObj) Is Line Then
Dim tempLine As Line = theTaggedObj
lw.writeline(" start point: " & tempLine.startpoint.tostring)
lw.writeline(" end point: " & tempLine.endpoint.tostring)
End If
Next

Next

lw.close
End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

End Function

End Module

I tried your code but it is showing the "AskDraftingCurveParents" is not a member of NXOpen.UF.UFDraw.

Bhavik S.

Hello,
the code is working in NX 10.
I am using NX9 for some programs. So how to do it in NX9 ?

Bhavik S.

If you are using "exact" views in NX 9, then there is no way to do it. The .AskDraftingCurveParents function wasn't added until NX 10. If you are using the "exact pre NX 8.5" view type in NX 9, then there are other functions to get the curve parents.

However, I don't think that NX 9 supports sketching the section cut line. I believe that was also added in NX 10. In NX9, you specify locations for the section cut legs.

Thanks for the information.
Now I will try it in NX10.
And if i need any help will post my doubt over here.

Bhavik S.

I am trying to automate the section cut in NX9. If is there any startup code then it it helpful to me.

Bhavik S.