My guess is that your code indeed ended up with some special characters - perhaps not exactly a "?" but other ones that are not visible in the iLogic editor.
This assumption is supported by the fact that:
- when you copy pasted your code into the discussion forum, then the formatting got messed up and "?" characters appeared
- the error said "Error on Line 37: 'kHor' is not a member of 'Inventor.BreakOrientationEnum'." - i.e. there was something in between "kHor" and "izontalBreakOrientation" that prevented the iLogic interpreter from processing the complete string of "kHorizontalBreakOrientation"
- once you rewrote some of the parts they started working
I would suggest copying all your code from the iLogic editor into Notepad and see what you get (maybe by now you removed all the nasty special characters by rewriting things, but maybe not) If some funny characters show up or lines are broken up wrong, then correct those and then copy/paste back the code from Notepad into the iLogic editor.
To help us to resolve this error:
"Error on Line 49 : 'view' is ambiguous, imported from the namespaces or types 'Inventor, System.Windows.Forms'."
can you post the complete text of your rule?
To avoid formatting problems, please copy and paste the text to Notepad. Then save the file as a txt file, and attach that file to your post.
Hello Adam and Mike,
Thank you for helping sofar.
It's a few weeks ago that i have worked on the rule, because of i had more functions than only do engineering work.
I hope you can remember my problem, and help me solve it.
In this post, i place the textfile 'Rule0' with the iLogic rule from the .idw.
Thanks in advance!
Sub Main Teller=iTrigger0 'iLogicVb.RunRule("Gestandaardiseerde rol", "Rule0") Dim BreakWithFactor As Double Dim Bmaat=Parameter("Gestandaardiseerde rol.iam", "Bmaat") Select Case Bmaat Case <400 ActiveSheet.View("Lengteaanzicht").ScaleString="1:
2" Case <1000 ActiveSheet.View("Lengteaanzicht").ScaleString="1: 5" BreakWithFactor=5 Case <1250 ActiveSheet.View("Lengteaanzicht").ScaleString="1: 7,5" BreakWithFactor=7.5 Case >1250 ActiveSheet.View("Lengteaanzicht").ScaleString="1: 10" BreakWithFactor=10 End Select If "1:2" IsNot ActiveSheet.View("Lengteaanzicht").ScaleString Then DeleteBreaks End If End Sub Sub DeleteBreaks If (ActiveSheet.Name <> "Rol_compleet:1") Then Return Dim viewL = ActiveSheet.View("Lengteaanzicht") Dim view = viewL.View If (view.BreakOperations.Count > 0) Then view.BreakOperations(1).Delete End If Dim xMid As Double = ActiveSheet.Sheet.Width / 2 'Helft van papierbreedte Dim yMid As Double = ActiveSheet.Sheet.Height / 2 'Helft van papierhoogte Dim modelDocName = IO.Path.GetFileName(viewL.ModelDocument.FullFileNa me) Dim Bmaat As Double = Parameter("Gestandaardiseerde rol.iam", "Bmaat") 'If (Bmaat > 1000) Then Return MessageBox.Show(Bmaat, "Bmaat=") MessageBox.Show(Bmaat, "Bmaat=") Dim breakWidth As Double = (((Bmaat-300)/BreakWithFactor)) Dim startPt = ThisApplication.TransientGeometry.CreatePoint2d((x Mid - (breakWidth*0.05)), yMid) Dim endPt = ThisApplication.TransientGeometry.CreatePoint2d((x Mid + (breakWidth*0.05)), yMid) MessageBox.Show(breakWidth, "Goed") 'view.BreakOperations.Add(BreakOrientationEnum.kHo rizontalBreakOrientation, startPt, endPt) ', BreakStyleEnum.kStructuralBreakStyle, 10, 0.3) End Sub
It looks like you fixed the compile error that you posted before. Here's an updated version that fixes a few other problems in the rule.
- BreakWithFactor is shared between the two Subs. It won't work if it's declared only in Main. The easiest way to do it is to declare it outside the Subs (at the VB Class level). I moved Bmaat there as well.
- IsNot does not generally work for string comparison. Use <> instead.
- Getting the midpoint of the sheet won't work unless the view is centered. It's better to use the view center. (I think we posted a simple example using the sheet center. We should have used the view center there as well.)
- The line to Add the break operation had an extra right parenthesis.
Thanks for sharing that knowledge!
I didn't know that lines between 'subs' are also read by VB. I've copied your attachment to the iLogic rule, and it works fine! Thereafter, I was busy with figuring out how the value of breakWidth works; and the view is always between the drawing sheet.
Now, I would use not only an horizontal break on a view, but on vertical views too. (So that the length-shortening is in vertical direction). It gives me some bugs, while i changes the endPt and startPt by gives the yMid an (postive and negative, respectively) offset, and xMid where only xMid.
After that, i saw the breakstyleorientation is horizontal vs. vertical, and then it works fine!
Thank you all for helping!
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.