Change layer ignore model sketch.

Change layer ignore model sketch.

DewayneH
Advocate Advocate
376 Views
1 Reply
Message 1 of 2

Change layer ignore model sketch.

DewayneH
Advocate
Advocate

I have a simple code we've been using for several years that works really well.

Basically it's used to put all model surface geometry on the phantom layer in a drawing.

 

I'm trying to stabilize the drawing dimensions by attaching to included model sketch geometry. 

The problem is, including the model sketch creates an error, because it is not considered in the rule.

 

How can I ignore the included sketch geometry to prevent the error? 

 

Dim doc As DrawingDocument 
doc = ThisDoc.Document 

Dim oDC As DrawingCurve
Dim oDCS As DrawingCurveSegment 
Dim oView As DrawingView = Nothing
Dim oDrawingViews As DrawingViews = ThisApplication.ActiveDocument.Sheets.Item(1).DrawingViews
 


If ThisDrawing.ModelDocument Is Nothing Then' 


Else

	' Iterate through drawing views
	For i = 1 To oDrawingViews.Count
	oView = oDrawingViews.Item(i)
	xView = oView.Name
	
		For Each oDC In doc.Sheets(1).DrawingViews(i).DrawingCurves 
			For Each oDCS In oDC.Segments 
				If Not oDCS.Parent.ModelGeometry.Parent.IsSolid Then 
					oDCS.Layer = doc.StylesManager.Layers.Item(9)
				End If 
			Next 
		Next
	Next
	
End If

 

 

Dewayne
Inventor Pro 2023
Vault Pro 2023
0 Likes
Accepted solutions (1)
377 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor
Accepted solution

Hi @DewayneH.  As you may know the ModelGeometry property of a DrawingCurve object returns the generic Object Type, because it might return several different Types of things.  You would have to test what Type of object is being returned in that situation to be sure.  Most of the time it is either an Edge or a Face.  The 'Parent' of both of those two objects is a SurfaceBody, and a SurfaceBody has the 'IsSolid' property that can be checked, so that worked most of the time.

Here is a version of your iLogic rule that will check for those two Types of objects, and if it is not one of those two, it won't do anything.

Dim oDrawing As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet = oDrawing.Sheets.Item(1)
If Not IsNothing(ThisDrawing.ModelDocument) Then 
	' Iterate through drawing views
	For Each oView As DrawingView In oSheet.DrawingViews
		For Each oDC As DrawingCurve In oView.DrawingCurves
			For Each oDCS As DrawingCurveSegment In oDC.Segments
				If Not IsNothing(oDCS.Parent.ModelGeometry) Then
					If TypeOf oDCS.Parent.ModelGeometry Is Edge Or _ 'Edge.Parent is SurfaceBody
						TypeOf oDCS.Parent.ModelGeometry Is Face Then 'Face.Parent is SurfaceBody
						If Not oDCS.Parent.ModelGeometry.Parent.IsSolid Then
							oDCS.Layer = oDrawing.StylesManager.Layers.Item(9)
						End If
					Else
						'the ModelGeometry object was not an Edge or Face
						'maybe it is from a sketch or something else
					End If
				End If 
			Next 
		Next
	Next
End If

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

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes