Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

The Doc say: <OutAttribute> [b]ByRef[/b] item_type As String How to declare this in vb

Status
Not open for further replies.

Ehaviv

Computer
Jul 2, 2003
1,012
Hi

please help understand the uf_ref doc.
the doc say:
<OutAttribute> ByRef item_type As String

how I declare this in vb journal ==>> ( Dim ByRef item_type As String ) ?
Because ==>> Dim item_type As String this not work.


Code:
UFClone.AskItemType Method  

Wrapper method for UF_CLONE_ask_item_type

Public Sub AskItemType ( 
	input_part_name As String,
	<OutAttribute> ByRef item_type As String
)



Code:
'-------------------------------------------------------------
   Dim item_type As String  <<== Not works

   Dim s As Session = Session.GetSession()
   Dim ufs As UFSession = UFSession.GetUFSession

   Dim input_part_name As String
   Dim ByRef item_type As String    <<== (ByRef) Do this possible

  ufs.clone.AskItemType(input_part_name, item_type)
 
Replies continue below

Recommended for you

Shortly

This throw compile error keyword not valid
Dim ByRef item_type As String


and this not work
Dim item_type As String

( Return item_type = null <<== ufs.clone.AskItemType(input_part_name, item_type) )

Thank you.
 
The "OutAttribute ByRef" just means that the method you are calling is going to modify the value of that variable; it will essentially become the output of the method. You declare the variable normally, but note that its value will be modified by the method.

Code:
Dim input_part_name As String = "some input part name"
Dim item_type As String = ""

ufs.clone.AskItemType(input_part_name, item_type)

After the code runs, the "item_type" variable will contain the item type of the given input part.

www.nxjournaling.com
 
Cowski
I'm very much thank you

Because I have understood and did as you posted.

But askitemtype (current clone operation part name, part item type) in my journal
Iteration always return null.
The assembly that I iterated have some items types.

Please can you give me a clue why so.

I'm very much thank you.
 
Hi ufsure and thank you.

Yes I know that.
So
What happened if I remove the
This statement
ufs.Clone.SetDefItemType("")
Then what will the default.
 
My clone operation is clone some components
And retain the rest.
And for them I set the above default
Statement.
 
Another question
If I have this
ufs.Clone.SetDefItemType("")

And I use also this
ufs.Clone.SetItemType("some type")
Is this statement do nothing
Because of the previous statement.
 
Hi ufsure.
After rereading the doc
And deeply thinking
I come to feel that you are right.

Tomorrow I will have access to nxmanager
And I will test it.

Because immediately after the statement
ufs.Clone.SetDefItemType("")
Nx set all the parts in the clone operation
To item type null.
And when I asked the item type for
A part i get null and that makes
My journal to go wrong.
 
Hi

I'm disappointed.

I removed ufs.Clone.SetDefItemType("")
From my journal.
and still I got null in askitemtype
Do someone have a thought about
This.
Why askitemtype always return null.

Thanks in advanced.
 
Hi ufsure and thank you for your wanting to help me.

'The code wrote in my company and I can not bring it out from company. (restriction issue)
'but this is the relevent recoded for the problem issue
'--------------------------------------------------------------

Dim pnItemType As String = Nothing
Dim addAssemblyPart As String = Nothing

ufs.Clone.Terminate()
ufs.Clone.Initialise(UFClone.OperationClass.CloneOperation)
Dim status As UFPart.LoadStatus = Nothing
ufs.Clone.SetDefFolder(":Cloned Parts")

'ufs.Clone.SetDefItemType("") ' with / without this still return nothing
'ufs.Clone.SetDefItemType("som_string") ' I tryied this and still return nothing

addAssemblyPart = "@DB/" & display_part.FullPath
ufs.Clone.AddAssembly(addAssemblyPart , status)

ufs.Clone.SetDefAction(UFClone.Action.Retain)

ufs.Clone.SetLogfile("c:\clone_log_file.txt")

' . . . . . . .

ufs.Clone.StartIteration()
Do
ufs.Clone.Iterate(prt_name)
If(prt_name = Nothing) Then Continue Do
If prt_name.Contains("/specification/") Then Continue Do

ufs.Clone.AskItemType(prt_name, pnItemType) ' this alwaisreturn nothing

If pnItemType = "UserPart" Then
ufs.Clone.SetItemType(prt_name, "UserPart")
else
ufs.Clone.SetItemType(prt_name, "ExtPart")
End If

Loop While (prt_name <> Nothing)

Dim faile As UFClone.NamingFailures = Nothing
Try
ufs.Clone.PerformClone(faile)
Catch e As Exception
lw.WriteFullLine("NX Exception = " & e.ToString)
End Try
ufs.Clone.Terminate()

'--------------------------------------------------------------
'I replaced these statements:

If pnItemType = "UserPart" Then
ufs.Clone.SetItemType(prt_name, "UserPart")
else
ufs.Clone.SetItemType(prt_name, "ExtPart")
End If

'by this statements:

ufs.Clone.SetItemType(prt_name, "UserPart")

'To check if SetItemType works and indeed works




Code:
   'The code wrote in my company and I can not bring it out from company. (restriction issue)
   'but this is the relevent recoded for the problem issue
   '--------------------------------------------------------------

   Dim pnItemType As String = Nothing 
   Dim addAssemblyPart As String = Nothing
 

   ufs.Clone.Terminate()
   ufs.Clone.Initialise(UFClone.OperationClass.CloneOperation)
   Dim status As UFPart.LoadStatus = Nothing 
   ufs.Clone.SetDefFolder(":Cloned Parts")

   'ufs.Clone.SetDefItemType("")                               ' with / without this still return nothing 
   'ufs.Clone.SetDefItemType("som_string")                     ' I tryied this and still return nothing 

   addAssemblyPart = "@DB/" & display_part.FullPath
   ufs.Clone.AddAssembly(addAssemblyPart , status)
   
   ufs.Clone.SetDefAction(UFClone.Action.Retain)

   ufs.Clone.SetLogfile("c:\clone_log_file.txt")

' . . . . . . .

   ufs.Clone.StartIteration()
   Do
     ufs.Clone.Iterate(prt_name)
     If(prt_name = Nothing) Then Continue Do
     If prt_name.Contains("/specification/") Then Continue Do
                
     ufs.Clone.AskItemType(prt_name, pnItemType)                ' this alwaisreturn nothing

     If pnItemType = "UserPart" Then
       ufs.Clone.SetItemType(prt_name, "UserPart")
     else
       ufs.Clone.SetItemType(prt_name, "ExtPart")
     End If
 
   Loop While (prt_name <> Nothing)

   Dim faile As UFClone.NamingFailures = Nothing
   Try
     ufs.Clone.PerformClone(faile)    
   Catch e As Exception
     lw.WriteFullLine("NX Exception  =  " & e.ToString)
   End Try
   ufs.Clone.Terminate()

   '--------------------------------------------------------------
   'I replaced these statements:

   If pnItemType = "UserPart" Then
     ufs.Clone.SetItemType(prt_name, "UserPart")
   else
     ufs.Clone.SetItemType(prt_name, "ExtPart")
   End If

   'by this statements:

   ufs.Clone.SetItemType(prt_name, "UserPart")

   'To check if SetItemType works and indeed works
 
Note that the complete journal
Works as expected.

Except that it's recording the wrong
Item type. ( Not the one I want )
 
I'm thank both
For training to help me.

 
I'm thank both
For trying to help me.


 
I'm thank both of you.
For trying to help me.
 
Sorry ny English
Is not my first language.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor