project name change using macro

project name change using macro

k14348
Advocate Advocate
1,084 Views
5 Replies
Message 1 of 6

project name change using macro

k14348
Advocate
Advocate

this macro is to change the project name in a part document

Public Sub GetPropertySample()

 ' Get the active document.

 Dim invDoc As Document

 Set invDoc = ThisApplication.ActiveDocument

 ' Get the part number property.

 Dim invProjectProperty As Property

 Set invProjectProperty = invDoc. _

PropertySets.Item("Design Tracking Properties").Item("Project")

invProjectProperty.Value = "wall unit"

End Sub

 

i need to change the project name for  whole assembly by using one macro.

example my assembly contains 10 parts. this 10 parts project name should be "wall unit"

 

Can anyone help to create this kind of macros....

Thanks in advance.

0 Likes
1,085 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

Hi,

I believe you would got the answer for your query by now. If not then here below;

 

Dim oDoc As Inventor.AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument

' Get Assembly Component Definition
Dim oCompDef As AssemblyComponentDefinition
Set oCompDef = oDoc.ComponentDefinition

On Error Resume Next

Dim oCompOcc As ComponentOccurrence


For Each oCompOcc In oCompDef.Occurrences
'You code goes here

call GetPropertySample
Next

 

oDoc.Update

 

 

this macro is to change the project name in a part document

Public Sub GetPropertySample()

 ' Get the active document.

 Dim invDoc As Document

 Set invDoc = ThisApplication.ActiveDocument

 ' Get the part number property.

 Dim invProjectProperty As Property

 Set invProjectProperty = invDoc. _

PropertySets.Item("Design Tracking Properties").Item("Project")

invProjectProperty.Value = "wall unit"

End Sub

Message 3 of 6

k14348
Advocate
Advocate

yes, Now i learned to write macros. Anyhow thanks for your reply. you r from?

 

Thank you,

Regards,

karthikeyan M

+919962356080

0 Likes
Message 4 of 6

dgreatice
Collaborator
Collaborator

Hi All,

 

Did you try this code? I'd trying you code, but only main assembly Project Property are change, sub assemblys/parts are not change.

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 5 of 6

MechMachineMan
Advisor
Advisor

Here is a version that would work for all files:

 

Dim oDoc As Inventor.AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument

oNewProjectValue = "NewProjNum"

oSubDoc.PropertySets.Item("Design Tracking Properties").Item("Project").Value = oNewProjectValue
For Each oSubDoc AS Document in oDoc.AllReferencedDocuments
oSubDoc.PropertySets.Item("Design Tracking Properties").Item("Project").Value = oNewProjectValue
End Sub 

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 6 of 6

dgreatice
Collaborator
Collaborator

Hi @MechMachineMan

 

You have little miss, I fixed it :

 

Hi @k14348 this subject solved by @MechMachineMan :

 

Dim oDoc As Inventor.AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument

oNewProjectValue = "NewProjNum"

oDoc.PropertySets.Item("Design Tracking Properties").Item("Project").Value = oNewProjectValue
For Each oSubDoc AS Document in oDoc.AllReferencedDocuments
oSubDoc.PropertySets.Item("Design Tracking Properties").Item("Project").Value = oNewProjectValue
End Sub

 

 

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014