cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

HOW TO REMOVE THE REVISION BALLOON'S FROM CREO DRAWING TEMPLATE USING - VBAPI

avijayan-2
12-Amethyst

HOW TO REMOVE THE REVISION BALLOON'S FROM CREO DRAWING TEMPLATE USING - VBAPI

Hi Everyone,

  I have a drawing's in creo, which has been revised more than 50 times so my requirement is to remove the unwanted the revision balloon symbol according to customer need.

For Eg : Drawing is having 20 revision balloon's from that user want to specifically remove 5th revision balloon before releasing it for production.

is it possible with VBAPI.

If you need a better picture on the above please let me know, i will attach a drawing for this.

With Regards

Aghil.M 

1 ACCEPTED SOLUTION

Accepted Solutions

Hello Aghil Vijayan

For loop concept is correct.

You cannot List out IpfcDetailSymbolDefItem from IpfcDetailItemOwner

                Dim symbol As IpfcDetailSymbolDefItem = owner.ListDetailItems(symbolname, i)


Parthiban Kannan

href="https://www.linkedin.com/in/parthiban-kannan/" target="_blank"

View solution in original post

27 REPLIES 27

Hi Agil

I think you need to get the list of symbols & from the SymbolInstruction you've to check the text value then filter the symbol related to the specific revision and then erase that symbol item

You may need to use

IpfcDetailSymbolDefItem.ListDetailItems()

IpfcDetailSymbolDefItem.GetInstructions()

IpfcDetailSymbolInstInstructions.TextValues

IpfcDetailSymbolInstItem.Remove()

And It's my assumption only I don't have any experience with the symbol.

Parthiban Kannan

href="https://www.linkedin.com/in/parthiban-kannan/" target="_blank"

Hi Parthiban,

Thanks for the reply i will check this and will get back to you.

With Regards

Aghil.M

Hi Parthiban,

How are you. I am facing a small issue in placing a drawing symbol.

i am attaching the code, error and snap of my form. with this.

Kindly guide me to solve this up.

With Regards

Aghil.m

Hello Aghil Vijayan

I found the reason for error on your code

The parent of IpfcDetailSymbolDefItem is not the IpfcDrawing, Use IpfcDetailItemOwner as the parent for IpfcDetailSymbolDefItem.

The Parent of IpfcDetailItemOwner is IpfcMode2D.

Use the below code to retrieve the Symbol Definition. It's working fine for me

   Try

            BSession = AConnection.Session

            Model = BSession.CurrentModel

            Model2Ds = CType(Model, IpfcModel2D)

            Dim IDetailOwner As IpfcDetailItemOwner = CType(Model2Ds, IpfcDetailItemOwner)

            Dim IRetSymbol As IpfcDetailSymbolDefItem = IDetailOwner.RetrieveSymbolDefinition(

                tb_SymbolName.Text,

                Nothing,

                Nothing,

                False)

            MessageBox.Show(IRetSymbol.GetInstructions.FullPath)

        Catch ex As Exception

            MessageBox.Show(ex.ToString, "Failure")

        End Try

Parthiban Kannan

href="https://www.linkedin.com/in/parthiban-kannan/" target="_blank"

Hi Parthiban,

So sorry for the late reply i was on vacation due to this long holiday.

Thanks a lot for the help,and big salute for explaining where i have made mistake. as you mentioned i have re-written the code please find the attachment.

Here i have a small doubt parthiban. "tb_SymbolName.Text"(This is from your program) how should i define this.

what i have done in my code is the name of "TEXTBOX" i have given but when i am giving the ".TEXT" extension its showing a error.

What may be the reason for this.

With Regards

Aghil.M

Hello Aghil Vijayan,

Here Am directly used the Symbol name from Textbox value. I've used WPF Textbox property Text. You can replace that with your required symbol name as String Value

Parthiban Kannan

href="https://www.linkedin.com/in/parthiban-kannan/" target="_blank"

Hi Parthiban Kannan

First of all so sorry for disturbing you. but i dont know any other source to get help in this topic. so please help me up.

In the attachment i have kept my code and the error snap what i am getting. the error is actually the same what was before.

I need few info from you.

1. When we give the symbol name and ask creo to retrieve don't we have to specify the file path in the code (or will it retrieve from the default location as per config file).

2. In your code you have mentioned symbol name as "filename.TEXT" but when i am declaring like that i am getting error in my code please see below line in red color.(usally extension for            symbol will be ".sym" right then why ".TEXT" .

            Public Sub placeSymbol(ByRef session As IpfcSession, _

                                                 ByVal abcd.text As String

                Dim owner As IpfcDetailItemOwner = CType(drawing, IpfcDetailItemOwner)

                Dim symbol As IpfcDetailSymbolDefItem = owner.RetrieveSymbolDefinition(abcd.text,

                                                                                                                             Nothing,

                                                                                                                             Nothing,

                                                                                                                             False)

3. Please go through this attachment and kindly guide me where i have done mistake.

Waiting for your reply.

With Regards

Aghil.M

Hello Aghil Vijayan

            Dim IRetSymbol As IpfcDetailSymbolDefItem = IDetailOwner.RetrieveSymbolDefinition(

                tb_SymbolName.Text,

                Nothing,

                Nothing,

                False)

Actually here, tb_SymbolName.Text is the WPF User interface Text box named tb_SymbolName which have the property TEXT. I directly called the textbox value as parameter here. You need not to use tb_SymbolName.Text. Just use your own symbol name as String. And you don't need to use (.sym). Just use the symbol name without extension

Parthiban Kannan

href="https://www.linkedin.com/in/parthiban-kannan/" target="_blank"

Hi Parthiban Kannan

Thanks for the reply. I understood that i didnt used " tb_SymbolName.TEXT" in my code. i used my TEXTBOX name only. But the way i declared the TEXTBOX name is wrong i think. " ByVal txtSName.Text As String " this is how i declared. Below you can see the error what i am getting.

Public Sub placeSymbol(ByRef session As IpfcSession, _

                                   ByVal txtSName.Text As String)     "HERE I DECLARED THE TEXTBOX NAME " txtSName.TEXT" " and i am getting below mentioned error here

Dim symbol As IpfcDetailSymbolDefItem = owner.RetrieveSymbolDefinition(txtSName.Text,     HERE as you said i called that TEXTBOX PARAMETER HERE

                                                                                   Nothing,

                                                                                   Nothing,

                                                                                   False)

I am gettiing 2 error's

1    All parameters must be explicitly typed if any of them are explicitly typed.

2    Comma or ')' expected.   

With Regards

Aghil.M

You cannot declare the argument, You can only assign the value of parameter

Step 1:

Public Sub placeSymbol(ByRef session As IpfcSession, _

                                   ByVal txtSName.Text As String) 

Change this line as below

Public Sub placeSymbol(ByRef session As IpfcSession, _

                                   ByVal SymbolName As String) 


Step 2:

Where you're calling this Sub, at the place you have to mention the txtSName.Text


Note:

This problem not related to PTC Creo VB API. This is related to the Visual Basic Coding.

Please see the below link for how to pass the parameters

Passing Arguments by Value and by Reference (Visual Basic)

Parthiban Kannan

href="https://www.linkedin.com/in/parthiban-kannan/" target="_blank"

Hi Parthiban Kannan

Thanks for the reply. I have understood that the error is in VB that is why i was telling you i have declared the variable wrongly.

I have rewritten the code like this now.

Step : 01 ( I HAVE KEPT ONLY NEEDED LINES)

Public Sub placeSymbol(ByRef session As IpfcSession, _

                                   ByVal symbolname As String)

Dim symbol As IpfcDetailSymbolDefItem = owner.RetrieveSymbolDefinition(symbolname,

                                                                                   Nothing,

                                                                                   Nothing,

                                                                                   False)

Step : 02 (CALLING THE ABOVE FUNCTION)

Dim run As New pfcSymbol

        Try

            lblStatus.Text = ""

            If (txtSName.Text = "") Then

                MsgBox("Please enter Symbol Name", MsgBoxStyle.Critical)

            Else

                run.placeSymbol(asyncConnection.Session, txtSName.Text)

                lblStatus.Text = "Symbol Placed at Input Location"

            End If

Note : is this correct method.

Ya It is looking good.

Parthiban Kannan

href="https://www.linkedin.com/in/parthiban-kannan/" target="_blank"

Hi Parthiban Kannan

Thanks a lot brother let me try this and will come back to you on this.

Mean While i have a small doubt on how creo is retrieving the symbol from library. Since we are not giving any path to VB. it should be looking at the default location in config,pro file right.

Now is it possible to pass a location into VB so that it will check there.

With Regards

Aghil.M

Yes, It checks the symbol from the location what you've mentioned in the configuration file

pro_symbol_dir

Parthiban Kannan

href="https://www.linkedin.com/in/parthiban-kannan/" target="_blank"

Hi Parthiban Kannan

Thanks a lot for the help.

Now the adding symbol is worrking fine for me. I will try now the other two requirements of mine will try the same way.

Once again thankyou so much. If i get some stuck some where i will come back to you

With Regards

Aghil.M

Aghil Vijayan

You're welcome

Parthiban Kannan

href="https://www.linkedin.com/in/parthiban-kannan/" target="_blank"

Hi Parthiban Kannan

Hello Brother. I have written the code to remove the Symbol from drawing as per your guideline. now i getting an error in the highlighted line in PINK color.

i tried different possibilities but i am not able to select the active drawing sheet. Please show me a way to pass through this.

What i want to do is:

1. From the current active drawing sheet in my creo i want to remove all the symbols which user gonna enter.

2.This is the error i am getting.

With Regards

Aghil.M

Hello Aghil Vijayan

Dim sheet As IpfcSheetOwner = Nothing

You've assigned nothing to sheet number but called the Sheet Number

num = sheet.CurrentSheetNumber

It doesn't make any logic, that's why it throws an error. You've to assign the model to sheet owner.

I prefer to use for loop with Drawing.NumberOfSheets to check revision symbol in all the sheets

Parthiban Kannan

href="https://www.linkedin.com/in/parthiban-kannan/" target="_blank"

Hi Parthiban Kannan

As you said i have assigned sheet owner to the drawing. after assigning  how to get the sheet number or how to make program understand that active sheet is my sheet number.

1. See my updated code :

Public Class pfcIdentifySymbol

    Public Sub findsymbol(ByRef session As IpfcSession, _

                                  ByVal symbolname As String)

        Dim model As IpfcModel

        Dim drawing As IpfcModel2D

        Dim symInstructions As IpfcDetailSymbolInstInstructions

        Dim symItem As IpfcDetailSymbolInstItem

        Dim num As Integer

        Try

            model = session.CurrentModel

            drawing = CType(model, IpfcModel2D)

            Dim sheet As IpfcSheetOwner = CType(drawing, IpfcSheetOwner)

            num = sheet.NumberOfSheets

            Dim owner As IpfcDetailItemOwner = CType(drawing, IpfcDetailItemOwner)

            Dim symbol As IpfcDetailSymbolDefItem = owner.ListDetailItems(symbolname, num)    'Here after the "," i should specify the sheetnumber as object how to do that

            MessageBox.Show(symbol.GetInstructions.FullPath)

            symInstructions = symbol.GetInstructions()

            symInstructions.TextValues = symbolname

            symItem = drawing.SelectDetailItem(symInstructions)

            symItem.Remove()

2. Error Details

As you mentioned in your reply how to create the loop can you give me an idea for that.

With Regards

Aghil,M

Aghil Vijayan

     Dim Drawing  as IpfcDrawing = CType(Model, IpfcDrawing)

     Dim TotalSheets as Integer

     TotalSheets = Drawing .NumberOfSheets  'This gets the total number of sheets in the drawing.


' Implement the For loop. I am suggesting you check all sheets instead of an active sheet. If you need the specific sheet directly mentioned the sheet number


For i = 1 To TotalSheets ' Note here i is the required sheet number


           Dim owner As IpfcDetailItemOwner = CType(drawing, IpfcDetailItemOwner)

            Dim symbol As IpfcDetailSymbolDefItem = owner.ListDetailItems(symbolname, i)   

            MessageBox.Show(symbol.GetInstructions.FullPath)


Next



Parthiban Kannan

href="https://www.linkedin.com/in/parthiban-kannan/" target="_blank"

Hi Parthiban Kannan

Hi accept point what you said to check in all sheets. But still i am getting same error in that line, i tried with both "ipfcDrawing & ipfcModel2D"

I think the For loop is correct but the way we described "TotalSheets" i feel we made some mistakes i guess.

See the Below Code :

Public Class pfcIdentifySymbol

    Public Sub findsymbol(ByRef session As IpfcSession, _

                                  ByVal symbolname As String)

        Dim model As IpfcModel

        Dim drawing As IpfcModel2D

        Dim symInstructions As IpfcDetailSymbolInstInstructions

        Dim symItem As IpfcDetailSymbolInstItem

        Try

            model = session.CurrentModel

            drawing = CType(model, IpfcModel2D)

            Dim i As Integer

            Dim TotalSheets As Integer

            TotalSheets = drawing.NumberOfSheets

            For i = 1 To TotalSheets

                Dim owner As IpfcDetailItemOwner = CType(drawing, IpfcDetailItemOwner)

                Dim symbol As IpfcDetailSymbolDefItem = owner.ListDetailItems(symbolname, i)

                MessageBox.Show(symbol.GetInstructions.FullPath)

                symInstructions = symbol.GetInstructions()

                symInstructions.TextValues = symbolname

                symItem = drawing.SelectDetailItem(symInstructions)

                symItem.Remove()

            Next

With Regards

Aghil M

Hello Aghil Vijayan

For loop concept is correct.

You cannot List out IpfcDetailSymbolDefItem from IpfcDetailItemOwner

                Dim symbol As IpfcDetailSymbolDefItem = owner.ListDetailItems(symbolname, i)


Parthiban Kannan

href="https://www.linkedin.com/in/parthiban-kannan/" target="_blank"

Hi Parthiban Kannan

So can you suggest me what should i do to Solve this issue.

With Regards

Aghil M

Hi Parthiban Kannan

As you mentioned to list out "IpfcDetailSymbolDefItem" what should i do.

I am trying all possibilities but i am getting that same error.

Please guide me Bro.

With Regards

Aghil M

Hello Parthiban Kannan

Did you find any solution for this bro. To list out "ipfcDetailSymbolDefItem" what should i do.

With Regards

Aghil.M

Hello Aghil Vijayan

I think you've forgotten one thing. This is not my JOB. I won't work to find the solution. I can just suggest that's all,

Anyway, you've to workout to find your solution. Calm and study the VB API Guide thoroughly and you can achieve your solution.

All the best

Parthiban Kannan

href="https://www.linkedin.com/in/parthiban-kannan/" target="_blank"

Hello Parthiban Kannan

Thanks Bro for the help. I know very well its not your job. What i meant by solution is to give me some hint on that as per your guideline only i made changes in my coding

'The parent of IpfcDetailSymbolDefItem is not the IpfcDrawing, Use IpfcDetailItemOwner as the parent for IpfcDetailSymbolDefItem.

The Parent of IpfcDetailItemOwner is IpfcMode2D'

Now to get that list to IpfcDetailSymbolDefItem what should i do and how to get the sheet number to pass. that is where i am stacked up.

Its not like i will post a query here and wait for somebody's  reply mean while i am trying from my side too.. since i am new to this i face lot of issues in understanding the API'S and their Parent Child Relationship etc. That is why i am posting back to back question's.

Any Way i really appreciate and thank you for the help what you did. No hard feelings bro take care bye.

I will find solution by myself.

With Regards

Aghil.M

Top Tags