I'm new to writing "code" so this maybe a real softball question.
I'm designing tooling that is very similar, so I've made a generic model and assembly using interpart expressions. Now what I'm trying to do is create a .vb file that will ask me for the new name and then rename all the parts. What I did was record me renaming some of the components using journal. Then I opened the journal file in textpad and inserted the following code:
Dim cue As String = "Please enter Tool Drawing Number"
Dim title As String = "Drawing Number"
Dim label As String = "Drawing"
Dim Drawing = Snap.UI.Input.GetString(cue, title, label, 12345-678)
theSession.Preferences.Modeling.UpdatePending = False
Now I want to take the "Drawing" number and rename each component with it so it come out like this:
"GENERIC_PLATFORM_WD_ASSY" (the old part name)
"12345-678_ASSY" (the new part name)
So how do you get "Drawing" to append to part of the old part name?
This doesn't seem to work:
attributePropertiesBuilder8.StringValue = "(Drawing)_ASSY"
BTW I'm using NX9, Teamcenter 10 and I do have a SNAP license.
Solved! Go to Solution.
I'm not 100% sure what you're trying to do, but maybe this would help:
Option Infer On Imports Snap, Snap.Create Public Class MyProgram Public Shared Sub Main() Dim theSession = NXOpen.Session.GetSession Dim cue As String = "Please enter Tool Drawing Number" Dim title As String = "Drawing Number" Dim label As String = "Drawing" Dim dwgNumber = Snap.UI.Input.GetString(cue, title, label, "12345-678") theSession.Preferences.Modeling.UpdatePending = False InfoWindow.WriteLine(dwgNumber) ' Just for debugging, I suppose Dim part = Snap.Globals.WorkPart ' Or whatever part you're trying to rename Dim newName = part.Name & dwgNumber ' Append the drawing number part.SaveAs(newName) ' Save with new name End Sub End Class
Yes, Thank you. The part I was missing was the "& dwgNumber" code. I got this to work. Now I don't have to spend time renaming all my components one at a time. BTW can a journal.vb file call up another journal.vb file? Right now my rename program is separate form my main program. I was going to just copy and paste everything in one file but it would be easier to add to and update if I keep the files small.
> can a journal.vb file call up another journal.vb file?
If you're running your code from within the NX Journal Editor, then that code all has to be in one file. You can several functions in that one file, but only one file.
If you're compiling code (e.g. coding in Visual Studio or a similar IDE), then you can have as many files as you like. The only downside is that running the code that you compiled requires an "author" license of some sort (whereas running in the journal editor does not). But I think you said you have a SNAP authoring license, so you're OK.