VBA automated centerlines for a single part within an assembly drawing

VBA automated centerlines for a single part within an assembly drawing

ryanl7Q37Q
Contributor Contributor
463 Views
5 Replies
Message 1 of 6

VBA automated centerlines for a single part within an assembly drawing

ryanl7Q37Q
Contributor
Contributor

Hi,

 

I have a drawing view of an assembly file, and I am trying to determine the specific part occurrence within the assembly that each centerline and centermark is attached to. For centermarks, I can find the occurrence name by using: oSheet.Centermarks.Item(i).AttachedEntity.Geometry.ModelGeometry.ContainingOccurrence.Name

I cannot find a similar path for centerlines. Does this exist somewhere?

 

My goal is to generate automated centermarks and centerlines for the drawing view, then also use VBA to delete the ones that pertain to off-the-shelf parts that get attached to the main part that I am designing.

 

If this can't be done, is there any way when using the VBA command to create automated centermarks and centerlines to limit these to only apply to certain parts within the assembly drawing view? 

 

Thanks.

 

 

0 Likes
Accepted solutions (1)
464 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

Hi @ryanl7Q37Q.  Just a quick process suggestion... Maybe have multiple DVR's (DesignViewRepresentations) of the main model, with one of them having the 'off-the-shelf' stuff hidden (Visible = False).  Make sure the DrawingView is set to that DVR just before generating the centermarks and centerlines, then set the DrawingView to the normal DVR afterwards.  Just a quick idea that seems like an option.

DrawingView.DesignViewRepresentation 

DrawingView.SetDesignViewRepresentation 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6

Frederick_Law
Mentor
Mentor

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-F87857BE-15C7-4799-B308-7DA7E444AECD

Centerline skipped "AttachedEntity".

Also a special case of BisectorCenterline.

0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor
Accepted solution

The only direct options I have seen are in the special cases when the Centerline was created as a bisector, or based on a work feature.  The Centerline.GetBisectorEntities  method will return two GeometryIntent objects you could try to work backwards from.  And if the Centerline is based on a work feature, the Centerline.ModelWorkFeature property seems promising, if you could step up the 'parent' ladder from that object.

 

On another note, similar to my first suggestion.  You could start with the normal DVR, generate the centermarks & centerlines, then switch the view to the 'filtered' DVR, then loop through the ones that are no longer 'Attached', and delete them.  The same concepts would likely work for ModelStates and suppression, I would think.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 6

ryanl7Q37Q
Contributor
Contributor

The way I have things currently set up, GetBisectorEntities and ModelWorkFeature both return nothing. Since I am already using a lot of DVRs, I do not want to convolute that list by adding more, and since I am using iAssemblies, I don't believe that model states will work. My plan now is to have the program temporarily suppress all of the attached parts in the drawing view, then run the centermark/centerline creation, then un-suppress the attached parts. 

 

Thanks for that idea.

0 Likes
Message 6 of 6

ryanl7Q37Q
Contributor
Contributor

It worked. I was able to isolate the attached parts by checking each component occurrence name. I used "oView.SetVisibility CompOcc, False" to remove each occurrence temporarily from the drawing view, and simultaneously added each occurrence to an object collection. After the centermarks were applied, I toggled all the objects in the collection back to visible. Thanks for your help!