Can you please let me know the API to be used to get the Centerlines on a drawing view using work points.
Thank You
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.
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 !
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)
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.
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 .
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.
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.
Would you please tell me how to add centerlines(symmetry axis)for the following views ?
Aha,how are you going these days ? I'm sorry to cause you trouble again . I have met with another kind of centerlines problems,that is symmetry axis .Woule please tell me the API to create symmetry axis ?I want to create the two red horizonal centerlines in the figure attached .
Best wishes .
Aha,I have found a way to get centerlines:
Dim oCenterlines As Centerlines
Set oCenterlines = oSheet.Centerlines
Dim oDrawingCurve1 As DrawingCurve
Set oDrawingCurve1 = oSheet.DrawingViews(2).DrawingCurves.Item(2)
Dim oDrawingCurve2 As DrawingCurve
Set oDrawingCurve2 = oSheet.DrawingViews(2).DrawingCurves.Item(15)
Dim oGeometryIntent1 As GeometryIntent
Set oGeometryIntent1 = oSheet.CreateGeometryIntent(oDrawingCurve1)
Dim oGeometryIntent2 As GeometryIntent
Set oGeometryIntent2 = oSheet.CreateGeometryIntent(oDrawingCurve2)
Call oCenterlines.AddBisector(oGeometryIntent1, oGeometryIntent2)
Dim oDrawingCurve3 As DrawingCurve
Set oDrawingCurve3 = oSheet.DrawingViews(2).DrawingCurves.Item(1)
Dim oDrawingCurve4 As DrawingCurve
Set oDrawingCurve4 = oSheet.DrawingViews(2).DrawingCurves.Item(14)
Dim oGeometryIntent3 As GeometryIntent
Set oGeometryIntent3 = oSheet.CreateGeometryIntent(oDrawingCurve3)
Dim oGeometryIntent4 As GeometryIntent
Set oGeometryIntent4 = oSheet.CreateGeometryIntent(oDrawingCurve4)
Call oCenterlines.AddBisector(oGeometryIntent3, oGeometryIntent4)
The last problem is that there are so many drawingcurves on the views that I don't know how to choose a special curve from them.For example,I don't know which curve is the 14th curve. Is there any good way to choose the curves needed ?
Best regards !
Hope you have got most questions solved, I was not available to look into your questions last two days. For this question that you want to choose a specific drawing curve, my suggestion is that you can use either of below ways to find it:
1. If you want to annotate a drawing curve which from a specific model edge, that you could find the cooresponding drawing curve with the DrawingView.DrawingCurves(ModelEdge), with passing in the ModelEdge object that it would return the cooresponding drawing curve that you require.
2. If you just select(highlight) a drawing curve on a drawing view, and want to check which index it is in the DrawingCurves collection, below is a sample code for getting the index for the selected drawing curve:
Dim oDoc As DrawingDocument Set oDoc = ThisApplication.ActiveDocument ' say you have a drawing curve segment selected on the sheet Dim oSelectedCurve As DrawingCurve Set oSelectedCurve = oDoc.SelectSet.Item(1).Parent Dim oDrawingView As DrawingView Set oDrawingView = oSelectedCurve.Parent Dim oCurve As DrawingCurve Dim iIndex As Integer iIndex = 1 For Each oCurve In oDrawingView.DrawingCurves If oCurve Is oSelectedCurve Then Debug.Print "The selected drawing curve is the " & iIndex & "th curve on the drawing view." End If iIndex = iIndex + 1 Next
3. This is similar with the first way, but you could use the drawing curve type and/or coordinates to determine which curve is you need. Say you want to find a specific circular drawing curve with a specified diameter, that you could iterate all the drawing curves and check whether the DrawingCurve.ProjectedCurveType = kCircularArcCurve2d, and then check the arc's radius and its center position with your requirement.
There maybe other ways that you can find if you have specific rules/requirement for it:). Hope this helps.
Thanks a lot ,my friend ,for giving me so much help without any impatience .You're my good online teacher .Aha,I hope you can help me deal with the following problem nothing to do wih centerlines ,which I have submited on the Autodesk Inventor Customization board :
Is there any way to add weld symbols on a drawing ?
I'm sorry to give you trouble again .I can't thank you enough ,no matter whether it would be solved .
Sorry,what I want to say is :Is there any way to add weld symbols on the drawing through VBA .If not,Is there any way to create weld symbols automatically on the drawing .
Best wishes to you !
Hi,My teacher Zhang .I have tried the second way to choose the special drawingcurves on thedrawingview .
Unfortunately ,I failed ,trying the code without any result .Maybe there is something lost.I have add several lines to the code ,but there is no change ,still without rusults.En,would you please help me out ?Haha,I'm sorry to bother you every day.
Dim oDoc As DrawingDocument
Set oDoc = oapp.ActiveDocument
Dim oActiveSheet As Sheet
Set oActiveSheet = oDoc.ActiveSheet
Dim oDrawingCurveSegment As DrawingCurveSegment
Set oDrawingCurveSegment = oDoc.SelectSet.Item(1)
' say you have a drawing curve segment selected on the sheet
Dim oSelectedCurve As DrawingCurve
Set oSelectedCurve = oDrawingCurveSegment.Parent
Dim oDrawingView As DrawingView
Set oDrawingView = oSelectedCurve.Parent
Dim oCurve As DrawingCurve
Dim iIndex As Integer
iIndex = 1
For Each oCurve In oDrawingView.DrawingCurves
If oCurve Is oSelectedCurve Then
Debug.Print "The selected drawing curve is the " & iIndex & "th curve on the drawing view."
End If
iIndex = iIndex + 1
Next
Hi,my teacher Zhang ,I really can't thank you enough . The VBA code you gave me is completely right .It has saved much time for my work .It's exiting !The reason that I got no results lies in ” Debug.Print “.Haha,forgiving my poor technic!I have changed them to be “ MsgBox ".,that is
‘Debug.Print "The selected drawing curve is the " & iIndex & "th curve on the drawing view.’
To
‘MsgBox "The selected drawing curve is the " & iIndex & "th curve on the drawing view.’.
En,in my eyes you‘re number one !Well,the remaiming problem is about weld symbols,as I have explained above .Would you please give me a hand when you are free ?
Best wishes !
Yours sincerely Yimin Zhang
Glad to hear that you have pointed it out. As for create drawing weld symbol question I responsed to another post you created, please check it there.:)
dears can you give me updated code for this center line adding code ..coz in version of 2017 its cant longer supported
Can't find what you're looking for? Ask the community or share your knowledge.