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: 

Custom iProperties manipulation

2 REPLIES 2
Reply
Message 1 of 3
ralph.daub
544 Views, 2 Replies

Custom iProperties manipulation

If I try to delete a custom iProperty that isn't available, I get an error. How do I check if the custom iProperty exists, and if it does, then delete it? The macro that I have is listed below:

{code}
Public Sub UpdateFlatPatternParameters()
Dim partDoc As PartDocument
Set partDoc = ThisApplication.ActiveDocument

' Get the "User Defined Properties" property set.
Dim dtPropSet As PropertySet



' Delete the current G_L and G_W iProperties
Set dtPropSet = partDoc.PropertySets.Item("Inventor User Defined Properties")
dtPropSet("G_L").Delete
dtPropSet("G_W").Delete

' Add G_L and G_L properties with the respective values.
Dim invProp As Property
Set invProp = dtPropSet.Add(length, "G_L")
Set invProp = dtPropSet.Add(width, "G_W")

End Sub
{code}



What this macro does:
This macro macro was made to manipulate some custom iProperties on some of our Flat Pattern designs. It needs to delete the custom "G_L" and "G_W" variables if they exist (they are for Length and Width, that may hold a semi-static, broken value)

Then it re-creates a "G_L" and "G_W" variable with the expression "=" which will give the G_L and G_W a dynamic Flat Pattern extents value.

The user runs it by pushing a button that I will add to the Inventor menu bar. Additionally, would there be a better way to automate this process? There are a LOT of flat patterns in Vault that need to be updated, and with this button the flat patterns would be updated on a by-need basis.
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: ralph.daub


Add some error handling to catch the cases where
the property does not exist. See below for one method.

 

You should be able to write an external VB or
VB.NET program to reasonably quickly update iProperties in hundreds or even
thousands of files. You can use the Apprentice Server API in this program
to access IV files and manipulate their properties without the need to start IV,
or even have IV on the machine where the program is running.

 

 


If I try to delete a custom iProperty that isn't
available, I get an error. How do I check if the custom iProperty exists, and if
it does, then delete it? The macro that I have is listed
below:

{code}
Public Sub UpdateFlatPatternParameters()
Dim partDoc
As PartDocument
Set partDoc = ThisApplication.ActiveDocument

' Get the
"User Defined Properties" property set.
Dim dtPropSet As
PropertySet



' Delete the current G_L and G_W iProperties
Set
dtPropSet = partDoc.PropertySets.Item("Inventor User Defined
Properties")

 

 

 

'''''''''''''''''''''''' error handling added
here

 

On Error Resume
Next
dtPropSet("G_L").Delete

If Err Then

    Err.Clear

End If

dtPropSet("G_W").Delete
If Err
Then
    Err.Clear
End If
On Error Goto 0

 

''''''''''''''''''''''''

 

 


' Add G_L and G_L properties with the
respective <Flat Pattern Length/Width> values.
Dim invProp As
Property
Set invProp = dtPropSet.Add(length, "G_L")
Set invProp =
dtPropSet.Add(width, "G_W")

End
Sub
{code}

Message 3 of 3
ralph.daub
in reply to: ralph.daub

Thank you, the error handling worked perfectly:
{code}
On Error Resume Next
dtPropSet("G_L").Delete
If Err Then ' Error handling
Err.Clear
End If

dtPropSet("G_W").Delete
If Err Then ' Error handling
Err.Clear
End If
{code}

Where could I go to look at some examples of external VBA or VB.net programs that work with Inventor through this Apprentice Server API?

Thank you.

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

Post to forums  

Autodesk Design & Make Report