Get all center lines and center marks in a drawing

Get all center lines and center marks in a drawing

Lalchetaketan022
Contributor Contributor
1,849 Views
10 Replies
Message 1 of 11

Get all center lines and center marks in a drawing

Lalchetaketan022
Contributor
Contributor

Hi

 

Want to find out all the center lines and center marks created in drawing... Out of all these , filter is required among this many were created automatically and manually ?

0 Likes
Accepted solutions (1)
1,850 Views
10 Replies
Replies (10)
Message 2 of 11

WCrihfield
Mentor
Mentor

Hi @Lalchetaketan022.  I'm not really sure what you are wanting to accomplish with the centerlines and centermarks, but here is a fairly simple iLogic rule that will loop through all sheets of a drawing, and collect & count all the centerlines and centermarks, then report its findings to you at the end.  We will need more detailed information about your specific goals to further customize something in an attempt to meet your needs.

oDDoc = ThisDrawing.Document
Dim oCLs As New List(Of Centerline)
Dim oCMs As New List(Of Centermark)
For Each oSheet As Sheet In oDDoc.Sheets
	If oSheet.Centerlines.Count > 0 Then
		For Each oCL As Centerline In oSheet.Centerlines
			oCLs.Add(oCL)
		Next
	End If
	If oSheet.Centermarks.Count > 0 Then
		For Each oCM As Centermark In oSheet.Centermarks
			oCMs.Add(oCM)
		Next
	End If
Next
MsgBox("There were " & oCLs.Count & " Centerlines total found accross all sheets." & vbCrLf & _
"There were " & oCMs.Count & " Centermarks total found accross all sheets.",,"")

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 11

Lalchetaketan022
Contributor
Contributor

Thanks for your reply.

 

If I focus on center line only as of now, I can get only few center lines when I checked count through API.

 

If I right click to view in Inventor drawing and click on "Automated Centerlines", it generated centerlines for hole features. These centerlines are not counted when accessing from API.

 

Centerlines generated as symbols are getting recognized. These were created from Annotate tab ---> Symbols ---> Centerlines

0 Likes
Message 4 of 11

WCrihfield
Mentor
Mentor

Hi @Lalchetaketan022.  That is interesting.  I guess I have never looked into that before.  I know that when we use the DrawingView.SetAutomatedCenterlineSettings() method, it will return an ObjectsEnumerator of the stuff it creates in the view.  But using that will also generate new marks/lines in the view, if there are any qualifying view geometry to apply to that does not already have marks/lines.  I can see that for the centermarks, it doesn't matter if they were created by the automated tool, or created manually with the Center Mark tool, they are all found OK.  But the same may not always be true for centerlines.  In a couple of my own tests, both the centerlines I created using the regular manual Centerline tool, and the ones created by the automation tool were both identified and counted correctly by my code as expected, so I did not encounter this discrepancy myself yet.  I had not created any manual bisector type centerlines in those tests though, because the drawing was of a circular flange with a circular pattern of bolt holes though it.  So maybe it will not find those bisector centerlines.

 

I noticed that all centermarks and centerlines are automatically being put onto their own Layers.  All my centermarks are being created on a layer called "Center Mark (ANSI)", and my centerlines are being created on a layer called "Centerline (ANSI)".  Maybe we can take advantage of that fact.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 11

3DAli
Collaborator
Collaborator

Hi, 

 

is there a way to access the centerlines within a specific view, I checked the API object model and it seems centerline is only available under the sheet not view, and I want to process centerlines within a selected view, not the entire sheet, any ideas how that can be achieved?

 

appreciate you help

Best

Ali

0 Likes
Message 6 of 11

WCrihfield
Mentor
Mentor

Hi @3DAli.  This is one of those API side functionality requests that is somewhat common, and closely related to many others about dimensions and notes in drawings, where they want to find the parent view of those types of objects, when the API indicates that they belong to the Sheet also.  Various custom means have been created for tasks like these, and I even created an 'Idea' post in the Inventor Ideas forum about a similar / related request.

https://forums.autodesk.com/t5/inventor-ideas/drawingdimension-getassociatedview-drawingview/idi-p/1... 

 

However, in the case of Centerline & Centermark objects especially (but also GeometryIntent objects), I have discovered a slightly more direct, and seemingly built-in method for getting distinction.  I found it by 'snooping around' through iLogic resources that could be referenced / imported by our iLogic rules.  Due to this, a few special lines of code must be included within the 'Header' of the iLogic rule to enable its recognition & functionality.

 

Attached is a text file containing a pretty sweet iLogic rule example I prepared specifically for inspecting every Centerline and Centermarks on the 'active' Sheet of the 'active' DrawingDocument, and grouping them by which DrawingView they are associated with (using this new technique/tool), then highlighting them, per view, so the user can review the results / functionality for accuracy.  I have not done extensive testing on this method in various complex scenarios yet, so it may be possible that this method does not identify a view for every centerline or centermark.  In one case though, even though I had pre-existing centerlines in a couple views, they were not recognized at first, but once I deleted them, then added them back into those same views (looked exactly the same as before deleting them), that cause them to be recognized by the next run of the rule.  Not sure why, but I suspect they may have been added / created in an odd way initially.

Let me know how this works for you.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 7 of 11

WCrihfield
Mentor
Mentor

I believe I know a little more about why the initial centerlines were not recognized by this routine.  I believe they were created by the 'AutomatedCenterlineSettings' tool.  I suspect this is due to the situation that @Lalchetaketan022 pointed out earlier.  For some reason, if the centerlines were created by Annotate tab > Symbols panel > Centerline or Centerline Bisector tools, this code routine will find them.  However, if they were created by the AutomatedCenterlineSettings tool, they are sometimes not being found / recognized, for some reason.  This is not 100% true in every situation though.  For instance, in one drawing, I had a model of a cylindrical pin with parallel holes through it sideways a set distance apart, and 2 more holes through it sideways at different distance apart, with hidden lines showing, front, top, right, & iso views of it.  In that drawing, it will not find the centerlines that are made by the AutomatedCenterlineSettings tool, but will find the ones added the other way.  However, in another drawing documenting a part that is a metal ring with a circular bolt hole pattern (lots of small holes) around it, I can fully create all the centerlines & centerlines using the AutomatedCenterlineSettings tool, and this code routine will find them all just fine.  Not sure why.  Maybe a bug in how the AutomatedCenterlineSettings tool works.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 8 of 11

3DAli
Collaborator
Collaborator

@WCrihfield Thank you so much for sharing this insight, I will check this out and see if this could resolve that missing link, the type of center lines that I am interested in detecting is by work features inclusion, mainly work planes and those are different than the ones created from model geometry references such as edges.  once again thanks for sharing your experience, I supported the idea as well, voted for you

 

Cheers

Ali

0 Likes
Message 9 of 11

3DAli
Collaborator
Collaborator

@WCrihfield , 

 

this is cool, and I ran it, it works nicely, do you see any way to use the algorithm  here to say 

 

if centreline reference view  = "ABC" then

      Do something 

else

      Do something else

end if

 

Thanks

Ali

 

0 Likes
Message 10 of 11

WCrihfield
Mentor
Mentor
Accepted solution

Hi @3DAli.  Sure.  This simplified example below should satisfy that scenario.

AddReference "Autodesk.iLogic.Core"
Imports Autodesk.iLogic.Core
Imports Autodesk.FromIntent.InventorUtils
Sub Main
	Dim oDDoc As DrawingDocument = TryCast(ThisDoc.Document, Inventor.DrawingDocument)
	If oDDoc Is Nothing Then
		Logger.Debug("Rule named '" & iLogicVb.RuleName & "' exited because no DrawingDocument was obtained.")
		Return
	End If
	Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
	Dim oCLs As Inventor.Centerlines = oSheet.Centerlines
	If oCLs.Count > 0 Then
		For Each oCL As Centerline In oCLs
			Dim oCLView As DrawingView = Nothing
			Try : oCLView = DrawingDocumentUtil.GetDrawingView(oCL) : Catch : End Try
			If oCLView IsNot Nothing Then
				If oCLView.Name = "ABC" Then
					'do something
				Else 'view name does not match
					'do something else
				End If 'end of View name check
			End If 'end of View is Nothing check
		Next 'oCL
	End If 'end of Centerlines.Count check
	oSheet.Update
	If oDDoc.RequiresUpdate Then oDDoc.Update2(True)
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 11 of 11

3DAli
Collaborator
Collaborator

@WCrihfield , this is fantastic, thanks so much, I was trying to mark this as "Accept as solution", but can't see it on this thread, regardless, I truly appreciated it, and learned something new from you 🙂

 

Cheers

Ali

0 Likes