Hiding specific tangent edges, based on an input.

Hiding specific tangent edges, based on an input.

C_Haines_ENG
Collaborator Collaborator
802 Views
12 Replies
Message 1 of 13

Hiding specific tangent edges, based on an input.

C_Haines_ENG
Collaborator
Collaborator

This one is a reach, but is it possible to select a specific tangent edge created by a fillet, based on an input.

 

For example, if someone selected "Vertical", all of these vertical lines would be hidden. See image for reference:

 

chainesL5H3G_0-1668191950599.png

 

It would do this for all lines on a part view.

 

 

0 Likes
Accepted solutions (1)
803 Views
12 Replies
Replies (12)
Message 2 of 13

WCrihfield
Mentor
Mentor

Hi @C_Haines_ENG.  This might actually be possible, but would likely require a lot of code and time to develop, so I don't know if it would be worth it for you.  In theory, you could dig into the model, get a reference to that feature object, then supply that to the DrawingView.DrawingCurves property to get a set of geometry for that feature within the view (if any).  Then you could probably filter that returned geometry by what Layer they are on.  I would imagine that if those are 'tangent' lines, they would be on a layer similar to "Visible Narrow (ANSI)", if you were using ANSI standard.  The regular outer profile lines would most likely be on a different layer, like "Visible (ANSI)", instead, which is usually slightly thicker (obviously).  Once you have filtered the geometry objects, you could likely find one or more ways to turn their visibility off.  Just throwing the process in my mind out there.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 13

C_Haines_ENG
Collaborator
Collaborator

Would it be possible to search all drawingcurves and select only the ones in a vertical or horizontal orientation that are exactly 3 mm? Sadly all of the "visible" layers need to be on the same layer.

 

Can you extract length from the drawing curves?

0 Likes
Message 4 of 13

WCrihfield
Mentor
Mentor

Hi @C_Haines_ENG.  I don't have a good example to test this on, but you can give it a try, and maybe make any tweaks you think it may need, but this code below should be fairly similar to what you are talking about.  Right now, it is just set to process one specific view on the active sheet, by its index number, but you can change that part as needed.  After the view has been obtained, it then gets all drawing curves for that view into one variable.  Then as it loops through them, it checks to see if that geometry represents a 'tangent edge', and if not, skips to next geometry.  Then it checks to see if it is a straight line or line segment type geometry.  If so, it then measures its length from start point to end point, then attempts to account for view scale, then attempts to convert from 'database units' (centimeters in this case), to document units (which I assume is millimeters in this case).  Then, if that value equals 3, it then tries to set visibility of that geometry off for that view.

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oView As DrawingView = oSheet.DrawingViews.Item(2)
Dim oDCurves As DrawingCurvesEnumerator
oDCurves = oView.DrawingCurves
If oDCurves.Count = 0 Then Exit Sub
For Each oDCurve As DrawingCurve In oDCurves
	If oDCurve.EdgeType <> DrawingEdgeTypeEnum.kTangentEdge Then Continue For
	If oDCurve.CurveType = CurveTypeEnum.kLineCurve Or _
		oDCurve.CurveType = CurveTypeEnum.kLineSegmentCurve Then
		Dim oLength As Double = oDCurve.StartPoint.DistanceTo(oDCurve.EndPoint)
		oLength = oLength / oView.Scale 'divide by view scale
		'convert value from database units (centimeters), to document units (millimeters in your case)
		oLength = oLength / 10
		'MsgBox("Tangent Line Length = " & oLength,,"")
		If oLength = 3 Then
			oView.SetVisibility(oDCurve, False)
		End If
	End If
Next

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 13

C_Haines_ENG
Collaborator
Collaborator

It unfortunately doesnt seem to work, it just pulls almost random values. I have no clue whats going wrong. 

0 Likes
Message 6 of 13

WCrihfield
Mentor
Mentor

Hi @C_Haines_ENG.  After a little more testing and looking at the descriptions of these methods available, I noticed that the SetVisibility method does not work for DrawingCurve objects, or their underlying DrawingCurve.ModelGeometry in a situation like this.  I had almost forgot about digging down the next step below the DrawingCurve object, to its DrawingCurveSegment objects, which actually have a Visibility property.  Also, I wasn't doing the Double value comparison correctly, because it would seemingly never pass that equality test.  Doubles are odd to work with that way.  I created a test scenario with a bent sheet metal part in a drawing and finally got this code below to work for it, but I use inches instead of millimeters, so you may have to change the units a bit to suit your case.  In my tests, my part was .125 inches thick, so I ended up using a < & > test around the target value to get the value comparison to work.  I tried simply using the Round(value, 3), but that wasn't good enough.

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oView As DrawingView = oSheet.DrawingViews.Item(2)
Dim oDCurves As DrawingCurvesEnumerator
oDCurves = oView.DrawingCurves
If oDCurves.Count = 0 Then Exit Sub
For Each oDCurve As DrawingCurve In oDCurves
	If oDCurve.EdgeType <> DrawingEdgeTypeEnum.kTangentEdge Then Continue For
	If oDCurve.CurveType = CurveTypeEnum.kLineCurve Or _
		oDCurve.CurveType = CurveTypeEnum.kLineSegmentCurve Then
		Dim oLength As Double = oDCurve.StartPoint.DistanceTo(oDCurve.EndPoint)
		oLength = oLength / oView.Scale 'divide by view scale
		'convert value from database units (centimeters), to document units (millimeters in your case)
		UOM = oDDoc.UnitsOfMeasure
		If UOM.LengthUnits <> UnitsTypeEnum.kDatabaseLengthUnits Then
			oLength = UOM.ConvertUnits(oLength, UnitsTypeEnum.kDatabaseLengthUnits, UOM.LengthUnits)
		End If
		'MsgBox("Tangent Line Length = " & oLength, , "")
		'<<<< CHANGE THIS PART TO SUIT YOUR CASE >>>>
		If oLength > 0.1249 And oLength < 0.1251 Then
			For Each oDCS As DrawingCurveSegment In oDCurve.Segments
				oDCS.Visible = False
			Next
		End If
	End If
Next

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 13

WCrihfield
Mentor
Mentor

Also, I haven't tested enough with the view scale math, so the math may need to use an If...Then test, and have two versions, to suit every situation.  For instance, in my testing, my view scale was set to "2:1", because my part was fairly small, but if your view's scale is set to something line "1:25", where it is a fraction of a whole, I'm not sure if the math would also need to change to keep the line length correct.  There may need to be a test of if the scale is greater than, or less than one, and use different math for each case, but like I said, I did not do enough testing this time to figure that part out.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 8 of 13

C_Haines_ENG
Collaborator
Collaborator

I really am unsure with whats happening, perhaps lines created by fillets are not tangent edges? 

 

Firstly, im only recieving 3 values of tangent edges where there should be atleast 7. On top of that the lengths im getting are really really weird. Like 7.51323. The scale of the draiwng is 1/8 and all dimensional values are whole numbers so I shouldnt be getting this problem.

 

EDIT: I see the problem now, the "Corners" created by filleted edges (as shown in the original image I posted) are not tangent edges? They dont register as such regardless. They may just be registering as normal lines or something else. I cant seem to garble the code together to allow me to find the type by selecting it. Is it because its technically a curved line in the model file?

 

Is there a different way to retrieve the length of a tangent edge?

0 Likes
Message 9 of 13

JelteDeJong
Mentor
Mentor
Accepted solution

Not sure if this is what you are looking for but give it a shot. It will remove lines like this:

JelteDeJong_0-1668463192635.png

Just start the rule and select the view that needs line removals.

Dim view As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a drawingview")

Dim refDoc As PartDocument = view.ReferencedDocumentDescriptor.ReferencedDocument
Dim refDef As PartComponentDefinition = refDoc.ComponentDefinition

For Each fillet As FilletFeature In refDef.Features.FilletFeatures
    For Each curve As DrawingCurve In view.DrawingCurves(fillet)

        If (curve.EdgeType = DrawingEdgeTypeEnum.kTangentEdge And
            curve.CurveType <> CurveTypeEnum.kLineCurve And
            curve.CurveType <> CurveTypeEnum.kLineSegmentCurve) Then

            For Each segment As DrawingCurveSegment In curve.Segments
                segment.Visible = False
            Next
        End If

    Next
Next

 

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 10 of 13

C_Haines_ENG
Collaborator
Collaborator

While that is a fantastic solution, I realized the potential problem here. 

 

My parts are solid extracts and thus do not retain the specifier of "FilletFeature"

 

Ive attached an example part file, the other solution of determining what line by length might be the only way I can go with this.

0 Likes
Message 11 of 13

WCrihfield
Mentor
Mentor

Hi @C_Haines_ENG.  I was right about the scale math needing a conditional statement to control it.  If the view's scale is greater than one, then the line's length will be longer than the model, and therefore its length needs to be divided by the view's scale.  And if the view's scale is less than one, the line will be shorter than the model, and therefore its length needs to be multiplied by the view's scale.  And if the view's scale is 1:1 (actual size), then no math is needed to accommodate for view scale.  That's probably why the measurements were not looking correct on your end.

Dim oScale As Double = oView.Scale
If oScale > 1 Then
	oLength = oLength / oScale
ElseIf oScale < 1 Then
	oLength = oLength * oScale
End If

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 12 of 13

C_Haines_ENG
Collaborator
Collaborator

Okay I've got it working enough that I can figure out how to peice this all together. Now how can I determine if its a horizontal or vertical line?

0 Likes
Message 13 of 13

WCrihfield
Mentor
Mentor

This is one way that comes to mind, since we are already accessing the DrawingCurve's start & end points to determine length.

If oDCurve.StartPoint.X = oDCurve.EndPoint.X Then
	'it it horizontal
ElseIf oDCurve.StartPoint.Y = oDCurve.EndPoint.Y Then
	'it is vertical
End If

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes