Reply
Solved! Go to solution

Adding a Ground Relationship to a part/sub-assembly

Could someone help me with this - I have tried everything I can think of but it always fails.

I have a macro that sets various properties for parts within an assembly - I want to add a bit more to it to ground the part at 0,0,0.

I can delete existing relationships and put the part in the correct position, but just can't get the adding a ground relationship.

 

My last effort was this, which I adapted from the Programmers guide -

objRelation3d = objRelations3d.AddGround(objOccurrence)

 

HP Z420 16GB RAM
Quadro K4000
ST7 MP10 on Windows 7 Pro 64.
4 REPLIES

Re: Adding a Ground Relationship to a part/sub-assembly

Hi beachcomber,
Are you sure that all relations are removed from the occurrence before you try to add the ground?
regards

JB
VS2015, SE ST10

Re: Adding a Ground Relationship to a part/sub-assembly

Yes, they are.

I have code to remove any relationships but I have also manually removed all relationships then run my macro.

Still doesn't apply the ground.

 

I'm off work until next week so will check it out anyway.

HP Z420 16GB RAM
Quadro K4000
ST7 MP10 on Windows 7 Pro 64.
Solution
Solution
Accepted by topic author beachcomber
‎01-30-2017 03:54 AM

Re: Adding a Ground Relationship to a part/sub-assembly

[ Edited ]

I believe your are using the wrong Relations3d collection object.

 

When you are going to delete existing relationships, then you will need to access the collection from your occurrence:

objOccurrence.Relations3d.Item(1).Delete()

 

When you are assembling occurrences in an assembly document, you will need to add relations in the document's collection:

objAsmDoc.Relations3d.AddGround(objOccurrence)

This is working for me!

(BTW: It is also used this way in the AddGround example in the SDK help)

Re: Adding a Ground Relationship to a part/sub-assembly

@MartinBernhard

Thanks. That works now.

HP Z420 16GB RAM
Quadro K4000
ST7 MP10 on Windows 7 Pro 64.