How to switch on "Export Object" for first solid in a part file

How to switch on "Export Object" for first solid in a part file

Rory_M
Advocate Advocate
374 Views
4 Replies
Message 1 of 5

How to switch on "Export Object" for first solid in a part file

Rory_M
Advocate
Advocate

Hi all,

We use derived parts in our workflow for the CNC guys so they can edit them to suit without affecting our original designs. These files have the link supressed so that updates are controlled manually, rather than automatically.

 

I've created an iLogic routine that creates these derived versions and saves them in the correct folder etc. with a single click. It also checks to see if the derived file already exists and if so it opens it, updates it to match the latest model, suppresses the link then saves and closes.

 

This is all working fine but we've had an issue whereby some original part files now have the "Export Object" flag turned off for solid1. This causes the derive update to fail.

 

This appears to be a known issue with inventor as there's other posts on the forum that relate to it but with no permanent fix. For example:

 

https://forums.autodesk.com/t5/inventor-forum/derived-part-solid-no-longer-exported/td-p/2700728

 

As a workaround, all I want to do is add to my routine so that the first thing it does is check the first solid in the part file and makes sure the "export object" option is turned on. Our parts tend to have a single solid so hopefully this should be relatively simple.

 

The majority of my routines are a mishmash of things I've found in these forums, I couldn't find anything related to this here or in the help, does anyone have any idea how to achieve this?

 

Thanks for any help

 

 

 

snippet 

0 Likes
Accepted solutions (1)
375 Views
4 Replies
Replies (4)
Message 2 of 5

basautomationservices
Advocate
Advocate

Hi Rory,

 

I use a script to create parts from a multibody solid and this is how I select one solid only. Maybe you can use this to re-enable the export status on Solid1

 

Sub test()

Dim doc As PartDocument
Set doc = ThisApplication.ActiveDocument

Dim dpcs As DerivedPartComponents
Set dpcs = doc.ComponentDefinition.ReferenceComponents.DerivedPartComponents

Dim dpc As DerivedPartComponent
Set dpc = dpcs.Item(1)

Call dpc.Definition.ExcludeAll

Dim dpe As DerivedPartEntity
For Each dpe In dpc.Definition.Solids
    If dpe.ReferencedEntity.Name = "Solid1" Then
        dpe.IncludeEntity = True
    End If
Next

End Sub

 

 

Contact me for custom app development info@basautomationservices.com. Follow below links to view my Inventor appstore apps.

Free apps: Smart Leader | Part Visibility Utility | Mate Origins

Paid apps: Frame Stiffener Tool | Constrain Plane Toggle | Property Editor Pro


0 Likes
Message 3 of 5

Rory_M
Advocate
Advocate

Thanks for the reply, it's much appreciated.

I should have been clearer in my original post, I'm having an issue with the original model, not the derived copy.

 

What the iLogic needs to do is:

 

1) I manually open a normal part file (this is not a derived file, just a bog standard part).

2) Start the iLogic routine

3) The iLogic needs to initially look for the first solid in the active file and make sure that it has "export object" switched on.

4) The rest of the routine then follows, this is the bit that deals with making a derived copy or updating an existing derived copy. This currently works fine.

 

It's point 3 that I can't figure out but I will have a look at your code and see if it helps.

 

 

0 Likes
Message 4 of 5

J-Camper
Advisor
Advisor
Accepted solution

This snippet should do what you are asking:

Dim oDef As PartComponentDefinition = ThisDoc.Document.ComponentDefinition 'change to however you are getting part document object
Dim FillThis As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
If oDef.SurfaceBodies.Item(1).Exported = False Then FillThis.Add(oDef.SurfaceBodies.Item(1))
If FillThis.Count > 0 Then oDef.ExportObjects(FillThis)

There is no error handling for a part with no solids. 

 

Let me know if you have any questions or if this is not working as intended

Message 5 of 5

Rory_M
Advocate
Advocate

That works perfectly, thank you very much!

0 Likes