Inventor Customization

Inventor Customization

Reply
Member
5 Posts
0 Kudos
Registered: ‎09-16-2012
Post 1 of 4

VBA: Distinguis​h hole features from other circles in drawing, add centermark​s.

568 Views, 3 Replies
09-17-2012 05:45 AM

I'm attempting to use VBA to put center marks on each hole in my drawing.

So far I have the following code:

    Dim oIntent As GeometryIntent
    Dim oCenterOfPart As Centermark
    
    'Add center marks to base view
    For Each oCurve In oBaseView.DrawingCurves ' <- need to identify Hole Features
        If Not oCurve.CenterPoint Is Nothing Then
            If oCurve.CurveType = kCircleCurve Then 'CurveTypeEnum
                Set oIntent = oSheet.CreateGeometryIntent(oCurve)
                Set oCenterOfPart = oSheet.Centermarks.Add(oIntent, True, True)
            End If
        End If
    Next oCurve
    
    'Add center marks to top view
    For Each oCurve In oTopView.DrawingCurves ' <- need to identify Hole Features
        If Not oCurve.CenterPoint Is Nothing Then
            If oCurve.CurveType = kCircleCurve Then 'CurveTypeEnum
                Set oIntent = oSheet.CreateGeometryIntent(oCurve)
                Set oCenterOfPart = oSheet.Centermarks.Add(oIntent, True, True)
            End If
        End If
    Next oCurve
    
    'Add center marks to right view
    For Each oCurve In oRightView.DrawingCurves ' <- need to identify Hole Features
        If Not oCurve.CenterPoint Is Nothing Then
            If oCurve.CurveType = kCircleCurve Then 'CurveTypeEnum
                Set oIntent = oSheet.CreateGeometryIntent(oCurve)
                Set oCenterOfPart = oSheet.Centermarks.Add(oIntent, True, True)
            End If
        End If
    Next oCurve

 

oBaseView is the DrawingView object representing the base view the code just placed. I also used VBA to place the projected views oTopView and oRightView. I want to add center marks to each hole when viewed from the end (as circles) and add centerlines when viewed from the top or side (as hidden lines).

 

I will be iterating through several models representing various handhold styles. The feet can be in many orientations, 99% of them are paralel to one of the origin planes (XY,YZ, or XZ).

 

This is what my code generates:

 

Capture.PNG

 

 (The centermarks that are selected are the ones I don't want the code to generate)

 

 This is what I WANT the code to generate:

Capture2.PNG

 

 

 1) How do I distinguish whether a circle curve originated because of a hole or because of another cilindrical feature?

2) How to I identify the correspoding hidden lines in the other views so I can add a center line?

 

(Reposted from: http://forums.autodesk.com/t5/Autodesk-Inventor/VBA-Distinguish-hole-features-from-other-circles-in-...)

Contributor
12 Posts
2 Kudos
Registered: ‎02-21-2012
Post 2 of 4

Re: VBA: Distinguis​h hole features from other circles in drawing, add centermar

09-17-2012 05:51 PM in reply to: CragMonkey

Hi CragMonkey 

 

With my automatic drawing program I call up the automatedCenterlines, the same as if you were to RMB on each view and select automated center lines.  

 

Code:

oSheet is the active drawing sheet,


oSheet.DrawingViews.Item(1).SetAutomatedCenterlineSettings()
oSheet.DrawingViews.Item(2).SetAutomatedCenterlineSettings()
oSheet.DrawingViews.Item(3).SetAutomatedCenterlineSettings()

 

In your drawing template yo need to set your default Automated centerlines,

Tools > Document Settings > Automated Centerlines > Select required centerlines.

 

This should set all your default centerlines for the three views

 

Ash

 

Ash

Dell - T1650
Intel(R)Xeon(R) CPU E3-1290 V2 @ 3.70GHz
16GB
64-Bit
Windows 7 Pro
Inventor 2013 Build: 138
Member
5 Posts
0 Kudos
Registered: ‎09-16-2012
Post 3 of 4

Re: VBA: Distinguish hole features from other circles in drawing, add centermark

09-18-2012 11:18 AM in reply to: 00ash00

The holes were created not by using the hole function, but instead by excluding that area during the extrusion. Inventor is seeing them both as "Cylindrical Features" - the result is the same as the other code.

 

However, when I create a hole table it knows the difference and correctly identifies the holes. I'm just not sure how to leverage that for this purpose.

ADN Support Specialist
1,352 Posts
81 Kudos
Registered: ‎06-12-2011
Post 4 of 4

Re: VBA: Distinguish hole features from other circles in drawing, add centermark

09-23-2012 11:12 PM in reply to: CragMonkey

Hi,

 

I did no find a direct way, but at least you can get DrawingCurve.ModelGeometry which is an edge. Next iterate Edge.Faces. If the face is a cylinder, get Face.CreateByFeature. Thus you can know if the feature is a hole feature or other features. Hope this helps.



Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post