×
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

Splitting a document or part name

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

RE: Splitting a document or part name

this forum is more about CATIA question, your is a VBA question.

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

newnumber = Val(Mid(CStr(yourNumber), 3, Len(CStr(thenumber)-4))) 

Eric N.
indocti discant et ament meminisse periti

RE: Splitting a document or part name

(OP)
Hi itsmyjob,
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

my code is more VBA, not sure how that will work in CATScript

Eric N.
indocti discant et ament meminisse periti

RE: Splitting a document or part name

(OP)
I'm not sure if this is me or the code doesn't work in cat script.
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

Assuming your string always has one and only one "." in it, try this piece:

CODE -->

myString = CATIA.ActiveDocument.Name
myNewString = Mid(myString , 3, InStr(myString , ".") - 5) 

RE: Splitting a document or part name

(OP)
Thanks cilici
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

(OP)
hi guys,
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

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