Inventor Customization

Reply
Member
rrdeveloper
Posts: 5
Registered: ‎07-13-2011
Message 1 of 18 (765 Views)

Add Centerlines through VBA

765 Views, 17 Replies
07-13-2011 05:57 AM

Can you please let me know the API to be used to get the Centerlines on a drawing view using work points.

Thank You

 

Employee
yuhanzhang
Posts: 455
Registered: ‎01-06-2009
Message 2 of 18 (758 Views)

Re: Add Centerlines through VBA

07-13-2011 08:36 PM in reply to: rrdeveloper

Use the CenterMarks.AddByWorkFeature to create the center marks from the work points, then call the Centerlines.Add to create a center line on the center marks.



Rocky Zhang
Inventor API
Manufacturing Solutions
Autodesk, Inc.

Active Contributor
WOREAM
Posts: 38
Registered: ‎08-06-2011
Message 3 of 18 (724 Views)

Re: Add Centerlines through VBA

08-06-2011 02:24 AM in reply to: yuhanzhang



Excuse me ,Mr(s) Zhang .I've created centermarks for a drawingview,but I don't know how to choose both the centermarks of each cylinder to create a centerline,because there are several  cylinders on the same drawingview.Can you tell what  should I do next?Woule you please give me a sample ?Thank you very much !
Active Contributor
WOREAM
Posts: 38
Registered: ‎08-06-2011
Message 4 of 18 (718 Views)

Re: Add Centerlines through VBA

08-06-2011 02:32 AM in reply to: yuhanzhang

Here is part of my code:

Dim oCentermarks As Centermarks
Set oCentermarks = oSheet.Centermarks
Dim oDrawingCurve As DrawingCurve
For Each oDrawingCurve In oView.DrawingCurves
 If oDrawingCurve.CurveType = kCircleCurve Or _
    oDrawingCurve.CurveType = kCircularArcCurve Or _
    oDrawingCurve.CurveType = kEllipseFullCurve Or _
    oDrawingCurve.CurveType = kEllipticalArcCurve Or _
    oDrawingCurve.CurveType = kBSplineCurve Then
 Dim oGeometryIntent As GeometryIntent
 Set oGeometryIntent = oSheet.CreateGeometryIntent(oDrawingCurve)
 Call oCentermarks.Add(oGeometryIntent, True, False)
 End If
Next

 

 

 

 

Dim oCenterlines As Centerlines
 Set oCenterlines = oSheet.Centerlines
 Dim oMarks As ObjectCollection
 Set oMarks = oapp.TransientObjects.CreateObjectCollection
 Dim oCentermark As Centermark
 For Each oCentermark In oSheet.Centermarks

oMarks.Add oCentermark

Next
 Set oGeometryIntent = oSheet.CreateGeometryIntent(oMarks)
 Call oCenterlines.Add(oMarks)


 

Active Contributor
WOREAM
Posts: 38
Registered: ‎08-06-2011
Message 5 of 18 (716 Views)

Re: Add Centerlines through VBA

08-06-2011 02:50 AM in reply to: yuhanzhang
Employee
yuhanzhang
Posts: 455
Registered: ‎01-06-2009
Message 6 of 18 (693 Views)

Re: Add Centerlines through VBA

08-07-2011 07:45 PM in reply to: WOREAM

This is up to you to determine which center marks you want to use to create a centerline. For example, if you want to create a centerline bases on the left(or right) two center marks, which have their position the same X-coordinate value, then you can compare their coordinates(CenterMark.Position). Or if you have other criteria for determining the center marks, just apply it to them.

 



Rocky Zhang
Inventor API
Manufacturing Solutions
Autodesk, Inc.

Active Contributor
WOREAM
Posts: 38
Registered: ‎08-06-2011
Message 7 of 18 (671 Views)

Re: Add Centerlines through VBA

08-09-2011 05:52 AM in reply to: yuhanzhang

Thank you very much for your replying.You have reminded me of solving the problem in answer way as following :

'添加中心线create centerlines with centermarks .
Dim oCenterlines As Centerlines
Set oCenterlines = oSheet.Centerlines
Dim oCentermark As Centermark
Dim oMarks As ObjectCollection
Set oMarks = oapp.TransientObjects.CreateObjectCollection

Set oCentermark = oSheet.Centermarks(8)
oMarks.Add oCentermark
Set oCentermark = oSheet.Centermarks(9)
oMarks.Add oCentermark
Call oCenterlines.Add(oMarks)
oMarks.Clear
Set oCentermark = oSheet.Centermarks(6)
oMarks.Add oCentermark
Set oCentermark = oSheet.Centermarks(7)
oMarks.Add oCentermark
Call oCenterlines.Add(oMarks)
oMarks.Clear
Set oCentermark = oSheet.Centermarks(1)
oMarks.Add oCentermark
Set oCentermark = oSheet.Centermarks(3)
oMarks.Add oCentermark
Call oCenterlines.Add(oMarks)

 

 

But the problem is that I don't know how to make centerlines in your way though I understand what you mean .

And the way above to create centerlines is not so convinient because I just don‘t know how to pick out the centermarks ,so I have to try again and again .

How can I create these centerlines without these centermarks ? 

Besides,please forgive me causing  you  so much trouble .

 

Employee
yuhanzhang
Posts: 455
Registered: ‎01-06-2009
Message 8 of 18 (664 Views)

Re: Add Centerlines through VBA

08-09-2011 07:33 PM in reply to: WOREAM

The Centerlines.Add would accept the CenterEntities collection with GeometryIntent objects included. So you firstly should create the GeometryIntent object which reference the center marks you want to create centerline on. Below is a snippet of code modified with yours:

 

Set oCentermark = oSheet.Centermarks(8)
Dim oCenterlinePt As GeometryIntent
Set oCenterlinePt = oSheet.CreateGeometryIntent(oCentermark)

oMarks.Add oCenterlinePt
Set oCentermark = oSheet.Centermarks(9)
Set oCenterlinePt = oSheet.CreateGeometryIntent(oCentermark)

oMarks.Add oCenterlinePt
Call oCenterlines.Add(oMarks)
oMarks.Clear

 Please try if it works for you.



Rocky Zhang
Inventor API
Manufacturing Solutions
Autodesk, Inc.

Active Contributor
WOREAM
Posts: 38
Registered: ‎08-06-2011
Message 9 of 18 (646 Views)

Re: Add Centerlines through VBA

08-10-2011 07:23 PM in reply to: yuhanzhang

Hello,Mr(s) Zhang.I appreciate it that you have given me so much advice .With your help,I have solved many difficult problems.But nowI hope you can help me with the following probiem(please forgive me for my poor English):How can I create chamfernotes using"Chamfernotes.Add"?Would you please give me an "VBA code"example? Thanks to you again and again.

Active Contributor
WOREAM
Posts: 38
Registered: ‎08-06-2011
Message 10 of 18 (617 Views)

Re: Add Centerlines through VBA

08-11-2011 08:19 PM in reply to: yuhanzhang

Would you please tell me how to add centerlines(symmetry axis)for the following views ?

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.