iLogic Rule to check scale in drawing

iLogic Rule to check scale in drawing

gildas.lincot
Contributor Contributor
1,241 Views
8 Replies
Message 1 of 9

iLogic Rule to check scale in drawing

gildas.lincot
Contributor
Contributor

Hi everyone!

I'm looking for to create an simple ilogic rule to check in a drawing if the scale of flat pattern view is the same of the sheet view. 

Is any one can help me to find information about flat pattern view ? is there a parameter or something like that to find directly or not the scale of a flat pattern view ?

 

Thanks for you help!

Sorry for my english...

Salut!

0 Likes
Accepted solutions (1)
1,242 Views
8 Replies
Replies (8)
Message 2 of 9

WCrihfield
Mentor
Mentor

I'm not really sure about what scale your wanting to check the Flat Pattern View's scale to, because the sheet doesn't really have a scale property, only the views.  But here is a fairly simple iLogic rule that will find any FlatPatternView within the active sheet of your drawing, and display its name, its Scale, its ScaleString, and whether or not it is inheriting its scale from a base view.

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Drawing Documents.",vbOKOnly, "WRONG DOCUMENT TYPE")
	Return
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
For Each oView As DrawingView In oSheet.DrawingViews
	If oView.IsFlatPatternView Then
		MsgBox("View Name = " & oView.Name & vbCrLf & _
		"View.Scale (Double) = " & oView.Scale.ToString & vbCrLf & _
		"View.ScaleString = " & oView.ScaleString & vbCrLf & _
		"View.ScaleFromBase = " & oView.ScaleFromBase, vbOKOnly, " ")
	End If
Next

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 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 9

Anonymous
Not applicable

@gildas.lincot  Are you refering to the scale required in the title block?  I've modified the code of @WCrihfield . 

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Drawing Documents.",vbOKOnly, "WRONG DOCUMENT TYPE")
	Return
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
For Each oView As DrawingView In oSheet.DrawingViews
	If oView.IsFlatPatternView Then
		If oView.Scale <> 1 / 2 Then 'If view scale is not equal to 1/2 (as required), Then
			oView.Scale = 1 / 2		 'Set to 1/2 as required
		End If
	Else
		MsgBox("No Flat Pattern View Found.")
	End If
Next
0 Likes
Message 4 of 9

gildas.lincot
Contributor
Contributor

Hi,

 

Thanks for your help!

"I'm not really sure about what scale your wanting to check the Flat Pattern View's scale to, because the sheet doesn't really have a scale property, only the views. "  

 

I understand what you mean and it's right. In fact i would check if the flat pattern view scale is the same as the first view sacle of the sheet. If it's not, a message box appear to say "the scale of flat pattern view is not good".

I will try to work on it today, if i've got time...

Salut !

0 Likes
Message 5 of 9

Anonymous
Not applicable

Is that custom parameter? Not "Initial View Scale"?scale.JPG

0 Likes
Message 6 of 9

WCrihfield
Mentor
Mentor
Accepted solution

So you are wanting something like this then?:

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Drawing Documents.",vbOKOnly, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oViews As DrawingViews = oSheet.DrawingViews
Dim o1stViewScale As Double = oViews.Item(1).Scale
Dim i As Integer
For i = 2 To oViews.Count
	If oViews.Item(i).IsFlatPatternView Then
		If oViews.Item(i).Scale <> o1stViewScale Then
			MsgBox("The 'Scale' of the Flat Pattern View named " & oViews.Item(i).Name & vbCrLf & _
			"does not match the Scale of the first view.", vbOKOnly + vbExclamation, " ")
		End If
	End If
Next

 

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

gildas.lincot
Contributor
Contributor

Hi,

Thanks for your help, here it's the rule i've create today:

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Drawing Documents.",vbOKOnly, "WRONG DOCUMENT TYPE")
	Return
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet

Dim BonneEch As Decimal
Dim oViews As DrawingViews = oSheet.DrawingViews
Dim o1stViewScale As Double = oViews.Item(1).Scale
Dim i As Integer

For i = 2 To oViews.Count
BonneEch=o1stViewScale
Next

For Each oView As DrawingView In oSheet.DrawingViews
	If oView.IsFlatPatternView Then
		If oView.Scale.ToString <> o1stViewScale Then
		Response = MessageBox.Show("Souhaitez vous corriger ?", "Mauvaise Echelle de la Mise à Plat", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
		If Response = vbYes Then
		oView.Scale = BonneEch
		Else
		MessageBox.Show("A VOS RISQUES ET PERILS !", "ALORS ?", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
		End If
	End If
	End If
Next

It's working well, perhaps it can be optimised...

Salut!

0 Likes
Message 8 of 9

NachoShaw
Advisor
Advisor

I did something similar a few years ago and the best approach back then was to check the flat pattern scale against the first base view scale. The view scale & the sheet scale can at times be different so if you need to make sure flat pattern scale matches the base view scale, compare them both.

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


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.


0 Likes
Message 9 of 9

Charlies_3D_T
Advocate
Advocate

@WCrihfield 

 

Hello,

 

I implemented your rule but for some strange reason it does nothing. I just pasted it. Any idea what i could check? But i think i know why. The initial view scale was took from the flat pattern. And then we compare it to a flat pattern scale. But i have placed a base view on the drawing after i made the flat pattern and this has an other scale so it's not checking that. 

 

Is it possible to add this also that he check every scale on the drawing? 

0 Likes