×
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

How to combine a directory with a filename producing a file specification (filespec) using NXOpen ?

How to combine a directory with a filename producing a file specification (filespec) using NXOpen ?

How to combine a directory with a filename producing a file specification (filespec) using NXOpen ?

(OP)
Hello Everyone,

Which API should i use to replicate the below function in UFCfi to get the file specification ?
Combine a directory with a filename producing a file specification (filespec)

Below is the data obtained from the NX help file (NxOpen.NET API Reference)


uc4575 (view source)


Defined in: uf_cfi.h


Overview

Combine a directory with a filename producing a file specification (filespec).
For example:

dspec = "/manager", ftype = 2, fname = "bar"

will produce fspec = "/MANAGER/BAR.PRT".

If the file name is a directory, using a filetype of 100 will merge the
directories. For example:

dspec = "/manager", ftype = 100, fname = "bar"

will produce fspec = "/MANAGER/BAR".


Environment

Internal and External


See Also

For description of file types see table




int uc4575
(

const char * dspec,
int ftype,
const char * fname,
char * fspec

)

const char * dspec Input Directory
int ftype Input File type
const char * fname Input File name
char * fspec Output Resultant file specification

RE: How to combine a directory with a filename producing a file specification (filespec) using NXOpen ?

(OP)
Thanks for the quick reply.
I am aware of the Path.Combine VB.NET function but the reason i require this method to be replicated is that i am trying to create a user defined symbol using NXOpen.To create the same i found a reference document on GTAC that replicates the above function in C.

When i am trying to create the symbol using my code i am getting a error saying Current SBF file cannot be opened and i feel that i need to make the file to be opened as the current file and then open it

PFB my code below (The line in bold is throwing the error)

Public Const SYMBOLDIMAOND1NAME As String = "DIAMOND1"
Public Const SYMBOLDIMAOND2NAME As String = "DIAMOND2"
Public Const SYMBOLDIMAOND1SBFFILENAME As String = "Dimaond1.sbf"
Public Const SYMBOLDIMAOND2SBFFILENAME As String = "Dimaond2.sbf"
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work

Dim displayPart As Part = theSession.Parts.Display
Dim ufs As UFSession = UFSession.GetUFSession
Dim lw As ListingWindow = theSession.ListingWindow

Dim Ht1 As Double
Dim Ht2 As Double
Dim Ln1 As Double
Dim Ln2 As Double

Dim symb_names() As String = Nothing
Dim num_symb As Integer
Dim symb_inf() As UFDrf.UdSymbolFontInfo = Nothing

ufs.Drf.AskSymbolDataFromName(SYMBOLDIMAOND1NAME, symb_names, num_symb, symb_inf)
Ht1 = symb_inf(0).height
Ln1 = symb_inf(0).length

Dim tagSymb As Tag = NXOpen.Tag.Null
Dim tag As Tag = NXOpen.Tag.Null
Dim symbol_data(2) As UFDrf.SymbolCreateData
Dim sUtil_dir As String = Nothing
symbol_data(0).symbol_name = SYMBOLDIMAOND1NAME
symbol_data(0).height = Ht1
symbol_data(0).length = Ln1
symbol_data(0).angle = 0.0
symbol_data(0).anchor_tag = tagSymb
Dim objPoint1() As Double = {50.0, 50.0, 0}
ufs.Curve.CreatePoint(objPoint1, symbol_data(0).anchor_tag)
ufs.UF.TranslateVariable("UGII_UTIL", sUtil_dir)
Dim sPath As String = ""
sPath = Path.Combine(sUtil_dir, SYMBOLDIMAOND1SBFFILENAME)
ufs.Drf.SetSpecifiedSbfFile(sPath)
ufs.Drf.PlaceSymbol(symbol_data(0), False, False, tag)


Please let me know if you have a alternate solution

RE: How to combine a directory with a filename producing a file specification (filespec) using NXOpen ?

If you are creating the .sbf files (ie they do not already exist on disk), perhaps you need to use the CreateSbfFile method.

www.nxjournaling.com

RE: How to combine a directory with a filename producing a file specification (filespec) using NXOpen ?

(OP)
No i already have a file created manually in the UGII directory of NX by the name Diamond1.sbf.
I need to place this symbol in my drawing.
How can i place this user defined symbol using code ?

RE: How to combine a directory with a filename producing a file specification (filespec) using NXOpen ?

CODE

Public Const SYMBOLDIMAOND1SBFFILENAME As String = "Dimaond1.sbf" 

Your file name in the code appears to be a misspelling of "diamond", does the file on disk have the exact same spelling?

www.nxjournaling.com

RE: How to combine a directory with a filename producing a file specification (filespec) using NXOpen ?

(OP)
Now why didn't i notice that before :( , Thanks for pointing out.
This code now works perfectly :), Thanks one again.

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