Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fillet Rename

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
419 Views, 4 Replies

Fillet Rename

Hi all

 

I was like a kid to VB programming... and i copied one of the program from this forum for renaming fllets... But it was always giving an error...

 

So can any one help me out from this please...

 

Sub changeFilletname()
    Dim ptDoc As PartDocument
    If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then
        MsgBox "please open a part document"
        Exit Sub
    End If
    Set ptDoc = ThisApplication.ActiveDocument
    Dim Fillet As FilletFeature
    Dim j As Integer
    Dim prefix As String
    prefix = "Fillet_"
    j = 1
    For Each Fillet In ptDoc.Feature.FilletFeatures
        Fillet.Name = prefix + IIf(j < 10, "0" + CStr(j), CStr(j))
        j = j + 1
    Next
End Sub

4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

Hi ,

You need to use part component definition to get all features.try this 

 

Sub changeFilletname()
Dim ptDoc As PartDocument
Dim ptDocDef As PartComponentDefinition
If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then
MsgBox "please open a part document"
Exit Sub
End If
Set ptDoc = ThisApplication.ActiveDocument
Set ptDocDef = ptDoc.ComponentDefinition
Dim Fillet As FilletFeature
Dim j As Integer
Dim prefix As String
prefix = "Fillet_"
j = 1
For Each Fillet In ptDocDef.Features.FilletFeatures
Fillet.Name = prefix + IIf(j < 10, "0" + CStr(j), CStr(j))
j = j + 1
Next
End Sub

Message 3 of 5
Anonymous
in reply to: Anonymous

Thank you very much :)....

 

I just want to know, Whether it was the same way by which we have proceed to rename work planes also...

Becasue i tried to change the code with respect to work planes... the code works fine for counting number of work planes but it was giving error to rename the work planes...

Can you please help me out in this also....

 

Sub changeworkplane()
    Dim ptDoc As PartDocument
    If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then
        MsgBox "please open a part document"
        Exit Sub
    End If
    Set ptDoc = ThisApplication.ActiveDocument
    Dim WorkPlane As WorkPlanes
        Dim j As Integer
    Dim prefix As String
    prefix = "Work Plane"
    j = 1
    MsgBox ptDoc.ComponentDefinition.WorkPlanes.Count
      For Each WorkPlane In ptDoc.ComponentDefinition.WorkPlanes
    WorkPlane.Name = prefix + CStr(j)
        j = j + 1
    Next
 
End Sub

 

Message 4 of 5
Anonymous
in reply to: Anonymous

Hi ,

As i told you earlier ,still you are missing PartComponentDefinition here.It's fine .Understand this example..

 

Sub changeworkplane()
    Dim ptDoc As PartDocument
    Dim planName As String
    Dim workPlaneType As Boolean
    Dim ptDocDef As PartComponentDefinition
    Dim prefix As String
    Dim WorkPlane As Inventor.WorkPlane
    Dim i As Integer
    Dim j As Integer
    i = 1
    j = 1
    
    If ThisApplication.ActiveDocument.DocumentType <> kPartDocumentObject Then
            MsgBox "please open a part document"
        Exit Sub
    End If
    
    Set ptDoc = ThisApplication.ActiveDocument
    Set ptDocDef = ptDoc.ComponentDefinition
        prefix = "MyPlane"
        MsgBox ptDoc.ComponentDefinition.WorkPlanes.Count
For Each WorkPlane In ptDocDef.WorkPlanes
    Set WorkPlane = ptDocDef.WorkPlanes.Item(j)
    planName = WorkPlane.Name
    workPlaneType = WorkPlane.IsCoordinateSystemElement
    
    If workPlaneType = False Then
      WorkPlane.Name = prefix + CStr(i)
      i = i + 1
    End If
    
    j = j + 1
Next
 
End Sub

 

 

 

Message 5 of 5
Anonymous
in reply to: Anonymous

Thank you Prakash... It was so kind of you to explain in detail :smileyhappy :

 

One last question... Actually i was not understanding the concept of Grouping..

 

For Example Fillet is grouped under Component Defintion --- Features --- FilletFeatures (Which has been called while Renaming)

and Work planes are grouped under --- Component Defintion --- workplanes

Likewise if i want to find out some thing else like facedraft or sketches.. is there was any simple way to do . I was using View--Objectbrowser to findout but i was not sucessful every time.

 

So.. It would be helpful if you can guide me in this also. Sorry if iam asking so many questions...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report