Hi all,
I'm attempting to create a model that autmotaically derives ready-to-go drawings. I've gotten pretty far in doing so but have a few issues with regards to dimensioning. As I'm sure you're aware, when the model changes, a dimension to that feature, which has been removed, is also deleted and some those dimensions do not return once the model is changed back.
I have looked into using different view representations, but have found that they do not accommodate feature supression.
My questions are:
Is there a way to program in the dimensioning of a view
Create center points for of of the holes and center lines
And for a feature note such as "Hole and Thread" dimensioning, when the model expands, the leader and text length do not change and proceed into the view. Is there a way to fix or anchor the text to a certain spot on the drawing, and have the leader length expand and change accordingly to that point.
If you would like farther information, or think a similar question would help, please ask. Thanks in advance for any help.
Mitch
Solved! Go to Solution.
This rule is going to be run within the Assembly, so I only wish to get the Active Assembly. I would like to do so without using the "ThisApplication.ActiveDocument" if possible as I want to pass all of the parts through this function to create each of their drawings. All of the parts will be in the same Folder so my thought is to pass the PartNumber through with it's extension.
Since the Assembly is open, I would get the document for this item (hopefully there is a way to do so for all parts)
Otherwise I intend to use a line like this:
oPartDoc = ThisApplication.Documents.Open("C:\Some\Crazy\Path\To\Your\Part\Here.ipt", False)
To invisible open the document
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
While I was waiting to get assistance for this problem, I subbed in "ThisApplication.ActiveDocument" to debug the rest of the code.
Now I'm sitting here laughing as I got through pretty well the whole code up until I attempted to actually place the dimension. Multiple Messages pop up telling me the size of each curve it is finding. once it finds the correct length of the dimension I'm looking for, I press Ok one more time and it should place the Dimension (This message process is simply for debugging).
At this point, the program acts as if it's going to freeze, and then eventually brings this error.
Error in rule: Rule21, in document: Rect_Transition_Chute_Generator.iam (MASTER iLogic Assembly)
Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
....... You know it's bad when it says "Catastrophic Failure".....
Attached you can find the full code that lead me to this Point. Keep in mind it's changed to "ThisApplication.ActivfeDocument" until we figure out if there's a way to fix that portion of code.
For ease in finding I have starred where I think it is going wrong
Thanks
Mitch
Mitch,
You forgot to attach the code.
If the rule is running within the assembly, use
ThisDoc.Document
to get the assembly document.
That would probably be helpful
At the moment I am not commenting the material due to the fact I am deleting and adding code quite often because of trial and error.
I will fully comment it once it is complete
********
I've changed the coding around only to correct the "ThisDoc.Document" and pass another variable through As Boolean to say whether or not it is the assembly, or I wish to open a part and activate it.
This code still works fine up to that same portion of code I have highlighted..... but this time I crashed Inventor
I have now commented most of the code
Keep in mind this is still a test case where a lot of the code is only based on the one drawing so far and attempting to place one dimension
You've certainly come a fair ways with your coding over the last few weeks.
Most of this deals with objects & methods I don't have much experience with, but I did notice a couple of things:
Whenever you pass a variable into a sub or function and you want the value of the varibale to be passed with it, you need to use the byval statement. ex:
Public Sub CreateLinearDimension (ByVal oDrawingDoc As Document, ByVal DrawingViewScale As Double, ByVal DimensionLength As Double, ByVal OffsetDistance As Double, ByVal ReferencedDim As Boolean)
Also, you'll have better success when comparing numerical values if you use the DoubleForEquals type instead of Double. DoubleForEquals uses a more "generous tolerance", if you will, when deciding if two numbers are =, <, or >. If you just use Double then IV will see 1 as <> to 1.00000000000000001.
These kind of errors can be difficult to troubleshoot, hopefully the other Mike will see something more substantial.
Thanks!
I figured I was cheating by not having the ByVal, and thanks for the tip on DoubleForEquals.
With a little trouble shooting and commenting things out, I figured out that it is definitley the way I add the Dimension Style which is causing the issue.
Otherwise, leaving this part out, the code works fine. I've tweaked a few more things from the last code attached but I don't think it's anything that would effect this because the error still occurs if I put the Style portion back in.
I'm guessing it's becuase I'm inputting a String while I should be inputting something else
Mitch
Mitch,
I haven't tried your code yet. Thanks for the info about dimension styles. Can you upload your template drawing?
ByVal is not required. It is the default, and you can leave it out. The code will behave the same.
You don't need DoubleForEquals unless you're comparing Double values. I don't see any cases of that in your rule.
I think you're right. Assuming this line is the one we're tlaking about:
oDimension = oSheet2.DrawingDimensions.GeneralDimensions.AddLinear(oPt, oIntent1, oIntent2, kLinearDimensionType, True, DimStyle)
When I look up DimensionStyle in the object browser I see that it is a type. I beleive you need to declare DimStyle as DimensionStyle and set it to a style rather than simply supplying a string.
"You don't need DoubleForEquals unless you're comparing Double values. I don't see any cases of that in your rule."
If DimLength = DimensionLength Then
"ByVal is not required. It is the default, and you can leave it out. The code will behave the same."
Didn't know that. For some reason I always thought that ByRef was default.
I looked up the same thing and am in the process of attempting to do so.
I was trying to figure out what to set it as though, if I declare "Dim DimStyle As DimensionStyle" I must still set:
DimStyle = ..........
I'm looking around to see if I must set it as a String at this point as I have done
DimStyle = "GT - ......"
Or something else as I can't seem to find anything in "DimensionStyle" that allows you to set the style or get a specific style. It seems to be for manipulating various properties of a style
Mike,
OK, thanks. I missed that. DoubleForEquals would be useful there.
Or instead you could use:
If Abs(DimLength -DimensionLength) < 0.00001 Then
I've been working on doing automated dimensioning, and solved it by doing something like this :
Dim DimStyle As DimensionStyle
Set DimStyle = oDrawDoc.StylesManager.DimensionStyles.Item("Whatever_Local_Dimension_Style_Name_Here")
iLogic would be the same without the 'Set'
Calling for the dimension to actually place looks, in my case, like :
Set oLinDim = oDrawDoc.ActiveSheet.DrawingDimensions.GeneralDimensions.AddLinear(oNewView.Position, intentMin, intentMax, kVerticalDimensionType, True, DimStyle)
I'm assuming that Abs allows me to set my own tolerance by the looks of it, this will help to.
Unfortunately I would have to strip the template down due to company aspects and get permission before I could give the template.
But I'm not sure that there is a need to so as I have not changed anything to do with the styles in code. The Standard being used is:
"GT - Fraction (ANSI)"
I simply copied this style and added a "(" in Prefix and ")" in Suffix
"GT - Referenced Fraction (ANSI)"
Mitch
I think the line MegaJerk posted is what you need, Mitch.
Abs() just finds the absolute value of an expression. That's a neat idea, and would be especially useful outside of iLogic where there is no DoubleForEquals. It's kind of like the expression I use to find if a number is even or odd. (If a/2 = Floor(a/2) then aIsEven = True)
Sorry MegaJerk I didn't see your post until now
I attempted what you have suggested but get this error
Error in rule: Rule21, in document: Rect_Transition_Chute_Generator.iam (MASTER iLogic Assembly)
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
I checked the Style names and they are the same, I've even copied the name directly from the Style Manager but it still brings this error
Mitch
Nevermind, re-pasted the Style Name and it worked for some reason
I will elevate you towards outer space! (I got a kick out of that)
Thanks everyone!
I have an idea of how I'm going to dimension between two lines, so I should be ok for a good portion.
I know some of you are working on this type of thing as well so I will post whatever I have if I finish without trouble.
Thanks Again
Mitch
Error in rule: Rule21, in document: Rect_Transition_Chute_Generator.iam (MASTER iLogic Assembly)
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
I usually get this error either because IV decided to switch an assembly to "Master" LOD (which it LOVES to do when your working with parts lists), or because I'm trying to change something that's locked from editing(i.e. a sheetmetal part's Thickness when it's set to use the sheetmetal style's thickness).
My guess is that you somehow triggered an assembly level rule that requires a custom LOD when the LOD was set to master. I include a sub at the beginning of every assembly rule that checks and sets as neccessary the LOD everytime it runs. If you think this is the problem I can post up the code, or you can probably find it by searching the forums.
I see. Rereading the situation and armed with the knowledge that you're aware of LOD problems and how to control them, I officially change my theory to: you had a booger where you were trying to set the dim style causing the code to try to set the style to one that doesn't exist. iLogic isn't smart enough to make one when one doesn't exist.
Can't find what you're looking for? Ask the community or share your knowledge.