Drawing view hatch hided and edited

Drawing view hatch hided and edited

manu.marjanen
Advocate Advocate
840 Views
4 Replies
Message 1 of 5

Drawing view hatch hided and edited

manu.marjanen
Advocate
Advocate

Can you hide Part:1 hatch using Ilogic?

And can you edit those hatch styles to be solid?  

 

manumarjanen_0-1632386838981.png

 

0 Likes
841 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

The short answer is yes...if you have the latest (2022) version of Inventor.  There is a special type of object called a 'SectionDrawingView' which is derived from the regular DrawingVeiw object, that you would need to get first by finding this view within the iLogic rule.  Once you get that, you just need to dig down a few levels deeper through the API object model of that object to get to the 'Hatch' related stuff (SectionDrawingView.HatchRegions.Item()).  The 'Item' at the end of that last line is a 'DrawingViewHatchRegion' object.  It has several properties that can be changed, including one that can hide the hatch.  I would have included more links to those lower level API objects in the online help area, but couldn't find stable links to them to provide.  Do you have Inventor 2022?

 

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
Message 3 of 5

WCrihfield
Mentor
Mentor

Here is a fairly quick & simple iLogic example of accessing the Hatch properties of a section view in a drawing.

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("A Drawing Document must be active for this rule to work. Exiting.",vbCritical, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
'find/get the section view
For Each oSheet As Sheet In oDDoc.Sheets
	For Each oView As DrawingView In oSheet.DrawingViews
		If oView.ViewType = DrawingViewTypeEnum.kSectionDrawingViewType Then
			Dim oSecView As SectionDrawingView = oView
			 If oSecView.HatchRegions.Count > 0 Then
				 For Each oHR As DrawingViewHatchRegion In oSecView.HatchRegions
					'oHR.Angle					'Read/Write - Double
					'oHR.ByMaterial			'Read/Write - Boolean
					'oHR.Color					'Read/Write - Color object
					'oHR.DoublePattern		'Read/Write - Boolean
					'oHR.HatchAreas			'Read Only - DrawingViewHatchAreas object
					'oHR.Layer					'Read/Write - Layer object
					'oHR.LineWeight			'Read/Write - Double
					'oHR.Pattern					'Read/Write - DrawingHatchPattern object
					'oHR.Pattern = oDDoc.DrawingHatchPatternsManager.Item(1)
					'oHR.Scale					'Read/Write - Double
					'oHR.Shift					'Read/Write - Double
					'oHR.Visible					'Read/Write - Boolean
					If oHR.Visible Then oHR.Visible = False
				Next
			End If
		End If
	Next
Next

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)

Message 4 of 5

JelteDeJong
Mentor
Mentor

Just a side node. the function used by @WCrihfield HatchRegions is only available from Inventor 2022.

JelteDeJong_0-1632411005799.png

Also finding the occurrence that belongs to a hatch might prove to be difficult.  I could not find a direct link between the hatch and the occurrence.You might be able to do this by getting a DrawingCurveSegment with the DrawingViewHatchArea.BoundaryGeometries(). And then use the code from this post "How to get an info on selected part in drawing view using VBA?"

Also selecting the hatch area manually seems to be a problem. So manipulate an individual hatch region seems to be very dificult.

 

 

 

 

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 5 of 5

WCrihfield
Mentor
Mentor

Hi @JelteDeJong.  It does seem maybe a bit odd to attempt to retrieve the 'model' from this depth below the drawing view object, but the DrawingViewHatchRegion object does have a SurfaceBody property, so it would seem like the natural/logical path back to the model.  The SurfaceBody then has both a 'Parent' and a 'ComponentDefinition' property.  The 'Parent' property says it returns a generic Object, because it could be multiple types of objects, but I believe that it will return a ComponentOccurrence if it was in the context of an assembly.  Just a thought.  If we were able to retrieve the ComponentOccurrence associated with that hatch, then we could get its 'Name' and see if it's the specific one we're targeting.  My code above obviously wasn't attempting to filter for a specific one though, as may have been needed.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes