Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

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

Status
Not open for further replies.

biw01

Automotive
Dec 31, 2011
152
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
 
Replies continue below

Recommended for you

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
 
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
 
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 ?
 
Code:
Public Const SYMBOLDIMAOND1SBFFILENAME As String = [highlight]"Dimaond1[/highlight].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
 
Now why didn't i notice that before :( , Thanks for pointing out.
This code now works perfectly :), Thanks one again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor