Included plane results in multiple centerlines

Included plane results in multiple centerlines

Vincent_Campas
Enthusiast Enthusiast
498 Views
5 Replies
Message 1 of 6

Included plane results in multiple centerlines

Vincent_Campas
Enthusiast
Enthusiast

Hi,

 

I am trying to get all the centerlines per view.
The centerlines are included planes.

 

I make the user pick the view and then search for all the included centerlines.

My first attemp was with this code:

	For Each oCenterline In oSheet.Centerlines
                oWF = oCenterline.ModelWorkFeature
		Try
			If Left(oWF.Name, 3) = "Ref" Then
				If oView.GetIncludeStatus(oCenterline) = True
					ClArray.Add(oCenterline)
				End If
			End If
		Catch
		End Try
	Next


But this gave me the wrong number of centerlines (correct amount x 3).
So i made this one now:

Function GetCenterlinesPerView(oView As DrawingView, oSheet As Sheet)
	
	Dim refDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
	Dim oPlanes As WorkPlanes = refDoc.ComponentDefinition.WorkPlanes
	
	Dim PlaneArray As New ArrayList
	Dim CLArray As New ArrayList 

	For Each oPlane As WorkPlane In oPlanes
		Try
			If Left(oPlane.Name, 3) = "Ref" Then
				If oView.GetIncludeStatus(oPlane) = True
					PlaneArray.Add(oPlane)
				End If
			End If
		Catch
		End Try
	Next
	MessageBox.Show(PlaneArray.Count & " Planes were recognized", "Title")

	
	For Each oCenterline In oSheet.Centerlines
		oWF = oCenterline.ModelWorkFeature
		If PlaneArray.IndexOf(oWF) > -1 Then
			CLArray.Add(oCenterline)
		End If
	Next
	
	MessageBox.Show(CLArray.Count & " Centerlines were linked", "Title")

	'Return ClArray
			
End Function


The workplane gives me the right number of included features

but when comparing the centerlines to the planes it results in a multiple of 3.

 

i need the centerline objects per view so i can get its start/endpoint to create sections (with a 150mm offset from the centerline)

 

 

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

Stakin
Collaborator
Collaborator

I guess you include the planes three times.Pls check it.

you can export the plane name  that referenced  by centerline to a file,  Or to show  with MessegeBox.

0 Likes
Message 3 of 6

Vincent_Campas
Enthusiast
Enthusiast

When getting the names of the planes it gives each plane name 3 times

 

No clue how it woud be possible to include it more then once.

also I only see 1 centerline on the view.

For including i use:

For Each oPlane As WorkPlane In oPlanes
	Try
		If Left(oPlane.Name, 3) = "Ref" Then
			'View.SetIncludeStatus(oPlane, True)
			Dim oCenterLine As Centerline = oCl.AddByWorkFeature(oPlane, View)
catch
end try
next

 

 

0 Likes
Message 4 of 6

Stakin
Collaborator
Collaborator

Another way,you don't need to count the centerline.

when you include the workplane to view, make a unique centerline name (As the red one Dim oCenterLine As Centerline)for every workplane and every view ,and use the name to access the every centerline when you need.

 

By the way

when you count the centerline ,you count All the centerline on the sheet,not just count the view's

so the centerline qty will wrong. The plane must be used times on the sheet. check it

	For Each oCenterline In oSheet.Centerlines
		oWF = oCenterline.ModelWorkFeature
		If PlaneArray.IndexOf(oWF) > -1 Then
			CLArray.Add(oCenterline)
		End If
	Next

 

 

                                             

Message 5 of 6

Vincent_Campas
Enthusiast
Enthusiast

Indeed, it gives me al the centerlines wich uses that plane as ref.

 

The problem is that including of the centerlines happens in another rule.

But i have found a workaround:
i search on the included planes per view.
I include the planes a second time, but name them now 

Dim ocl As Centerline = oSheet.Centerlines.AddByWorkFeature(oPlane, oView)

 And now i can work with each centerline it iterates trough.

The second addbyworkfeature doesn't give me any double lines, so i hope this method isn't harmful.

0 Likes
Message 6 of 6

Stakin
Collaborator
Collaborator
Accepted solution

there is many way to do this,You can include one plane as centerline in a view,and then use this centerline to create section view,when it be done,include anther one,and so on for next view。

The other way is don't include workplane,only get the plane modelspacedata,such as the vector,the orgin point,and then transfer to sheetspace,use the sheet width、height,to calculate out the secttionsketchline point you want。

In a word,it is not nessesary to count centerlines。

0 Likes