Hatch scale

Hatch scale

kresh.bell
Collaborator Collaborator
1,111 Views
8 Replies
Message 1 of 9

Hatch scale

kresh.bell
Collaborator
Collaborator

Hi,

is it possible to create an iLogic that could change the hatch scale for all hatch in that view in the drawing environment, with the possibility of selecting several predefined values, for example 0.05, 0.1, 1, ...

0 Likes
1,112 Views
8 Replies
Replies (8)
Message 2 of 9

JelteDeJong
Mentor
Mentor

If i understand you correct then what you want can be done with standard inventor functionality.

first create all hatch styles that you want.

hatch styles.png

then in your drawing select some thing that is hatched. and select the style that you want.

hatch choises.png

 

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 3 of 9

WCrihfield
Mentor
Mentor

How about this:

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oScales As New List(Of Double)
oScales.Add(0.05)
oScales.Add(0.1)
oScales.Add(1)
oScales.Add(1.25)
oScales.Add(1.5)
oScales.Add(2)
Dim oScale As Double = InputListBox("Select Scale.",oScales)
Dim oDSketch As DrawingSketch = oSheet.Sketches.Item(1)
oDSketch.Edit
For Each oHatch As SketchHatchRegion In oDSketch.SketchHatchRegions
	oHatch.Scale = oScale
Next
oDSketch.ExitEdit

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

If you have time, please... Vote For My IDEAS 💡and Explore My CONTRIBUTIONS

Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 9

WCrihfield
Mentor
Mentor

Sorry, first post timed out with error, so it sent the post twice.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 9

kresh.bell
Collaborator
Collaborator

Hi,

sometimes in one view I have really many hatches, my idea is to select the view and then the change the scale using iLogic, all the hatches at once without having to select the hatch one by one

0 Likes
Message 6 of 9

WCrihfield
Mentor
Mentor

Here's another code that allows for the view selection.

I wasn't sure if you wanted to select the view before running the rule, or if you wanted to select the view after running the rule, so I included code for both scenarios, and commented the one out.

 

Dim oDDoc As DrawingDocument = ThisDrawing.Document

'[for if you want to pre-select the view before running the rule
Dim oView As DrawingView
If oDDoc.SelectSet.Count = 0 Then
	MsgBox("Nothing was pre-selected. Exiting.", vbOKOnly, " ")
	Exit Sub
Else
	If oDDoc.SelectSet.Item(1).Type = ObjectTypeEnum.kDrawingViewObject Then
		oView = oDDoc.SelectSet.Item(1)
	Else
		MsgBox("The selected object is not a Drawing View object." & vbCrLf & _
		"Please Select a Drawing View Object, then run again.Exiting.", vbOKOnly, " ")
		Exit Sub
	End If
End If
']

'[or for selecting the view after you run the rule
'Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a View.")
'If oView Is Nothing Then
'	oAns = MsgBox("Nothing was selected. Exiting.", vbOKOnly, " ")
'	Exit Sub
'End If
']

Dim oScales As New List(Of Double)
oScales.Add(0.01)
oScales.Add(0.1)
oScales.Add(0.25)
oScales.Add(0.5)
oScales.Add(0.75)
oScales.Add(1)
oScales.Add(1.25)
oScales.Add(1.5)
oScales.Add(1.75)
oScales.Add(2)
oScales.Add(10)
Dim oScale As Double = InputListBox("Select Scale.",oScales)

Dim oSketch As DrawingSketch
Dim oHatch As SketchHatchRegion
If oView.Sketches.Count > 0 Then
	For Each oSketch In oView.Sketches
		oSketch.Edit
		For Each oHatch In oSketch.SketchHatchRegions
			oHatch.Scale = oScale
		Next
		oSketch.ExitEdit
	Next
Else
	MsgBox("There were no sketches within this view.",vbOKOnly," ")
End If

 

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

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 7 of 9

kresh.bell
Collaborator
Collaborator

probably I was not clear, if , for example, I click on detail view E,

E.jpg

 

and then run rule, this is shown to me

run.jpg

0 Likes
Message 8 of 9

WCrihfield
Mentor
Mentor

We might have to expand the check on the pre-selected object to include multiple compatible object types (SectionDrawingView object for example), then maybe adjust the code so it will work with any of those other object types.  I'll see what I can do tomorrow (leaving for the day right now.)

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 9 of 9

J-Camper
Advisor
Advisor

Unfortunately the hatched regions generated by Inventor, when using section tools, are not objects accessible through API.  The method in @WCrihfield's post is only for hatched regions created in a sketch.

 

At this time you must manually select hatch regions and change them the way @JelteDeJong mentioned.  I usually set my selection filter to Hatch only so you can use window selections:

temp_pic.JPG

 

If you are using sketches in you drawing views to hatch, then you can use the code @WCrihfield posted, but the view selection/ Object type check could be changed as follows:

	'Setup
	Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument
	Dim oView As DrawingView
	'View Selection
	If oDDoc.SelectSet.Count = 0 
		Dim PickThis As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select Drawing View")
		If IsNothing(PickThis) Then Exit Sub ' If nothing gets selected then we're done
		oView = PickThis
	Else
		If InStr(CType(oDDoc.SelectSet.Item(1).Type, ObjectTypeEnum).ToString, "DrawingViewObject") > 0
			oView = oDDoc.SelectSet.Item(1)
		Else
			MsgBox("The selected object is not a Drawing View object." & vbCrLf & _
			"Please Select a Drawing View Object, then run again.Exiting.", vbOKOnly, " ")
			Exit Sub
		End If
	End If

The "InStr" Check should pick up all types of DrawingViewObjects because they all end with the same text.

 

0 Likes