Splitting a document or part name
Splitting a document or part name
(OP)
Hi guys,
I have found this line of code that will remove the instance number from the part number.
strNewNumber = Split(CATIA.ActiveDocument.Name,".")(0)
Can anyone tell me if you can use this to edit the part number itself.
eg remove the first 2 numbers and the last 2 numbers? (123456789.1 to 34567.1)
I can't find anything that explains how to do this using this command
any help would be really appreciated.
thanks
Alan
I have found this line of code that will remove the instance number from the part number.
strNewNumber = Split(CATIA.ActiveDocument.Name,".")(0)
Can anyone tell me if you can use this to edit the part number itself.
eg remove the first 2 numbers and the last 2 numbers? (123456789.1 to 34567.1)
I can't find anything that explains how to do this using this command
any help would be really appreciated.
thanks
Alan





RE: Splitting a document or part name
you can turn your number into a string with CStr(thenumber) then doing a mid(thestring,x,y) to keep what you need, then convert back to a number with Val(theString)
in your case :
CODE --> VB/VBA
indocti discant et ament meminisse periti
RE: Splitting a document or part name
The question was about a catia script.
I have tried to find examples but with virtually no luck.
I have used the line I mentioned before in a bit of code for removing the instance number (someone here gave me, may have been you)
Thanks for the pointer its appreciated.
regards
Alan
RE: Splitting a document or part name
indocti discant et ament meminisse periti
RE: Splitting a document or part name
Keep getting a string mismatch error.
More than likely me but could someone tell me?
thanks
Alan
***********************************************************
Dim nSel
nSel = uSel.item(1).value.name
Dim nSel2
nSel2 = nSel
CStr(nSel2)
Dim nSel3
nSel3 = Val(Mid(CStr(nSel), 3, Len(CStr(nSel2)-4)))
*************************************************************
RE: Splitting a document or part name
CODE -->
RE: Splitting a document or part name
That seems to work removing the numbers from the front of the part number but removes the instance number when trying to remove the last 4 digits.
Is there away to keep the instance number ?
regards
Alan
RE: Splitting a document or part name
did it by doing to cuts one for the part number and one for the instance number.
if thers a better way it would be nice to know.
cheers
Alan