iLogic Coding to Create Automated Drawing

iLogic Coding to Create Automated Drawing

Anonymous
Not applicable
59,965 Views
133 Replies
Message 1 of 134

iLogic Coding to Create Automated Drawing

Anonymous
Not applicable

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

Accepted solutions (1)
59,966 Views
133 Replies
Replies (133)
Message 121 of 134

Anonymous
Not applicable

Hi! thanks a lot for your help on this.

im trying to understand this code, but it's to complex for me right now. Is it possible for you to adapt you code for the simple piece that i have attached? That way maybe I can start to understand the code and develop some coding for bigger pieces.

 

once again thanks for the help!

0 Likes
Message 122 of 134

Anonymous
Not applicable

Hi I have been trying to use the code to place dimesnions as done in the thread. I am having problems getting it to work though. Particularrly in one line as below.

 

 

"    oDimension = oSheet2.DrawingDimensions.GeneralDimensions.AddLinear(oPt, oIntent1, oIntent2, kLinearDimensionType, True, DimStyle)"

 

I have copied the code posted into visual studio and everything is fine except for KLinearDimesnion which visual studio says is not decalared? I have looked back through the supplied code and cant find anywhere where Klineardimension is declared in any version of the dimensioning code. Am I missing something?

 

Thanks

 

 

0 Likes
Message 123 of 134

nmunro
Collaborator
Collaborator

A couple of things.

 

When working in VB.Net you must use the fully qualified enumerated type, so the reference to the dimension type would have to be DimensionTypeEnum.kLinear...

 

Secondly, there is no kLinearDimensionType member in the DimensionType enumerator, Have a look in the help sysem for the options you have (horizontal, vertical, diameter, etc).

 

Neil

 

        


https://c3mcad.com

0 Likes
Message 124 of 134

waynehelley
Collaborator
Collaborator

Hi all,

 

I have been trying to use snippets of the script in order to automate dimension creation.

 

Can anybody see where I am going wrong i these scripts?

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
0 Likes
Message 125 of 134

waynehelley
Collaborator
Collaborator

If anybody could post an example of this code running in Inventor 2015, that would be great.

 

Wayne

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
0 Likes
Message 126 of 134

fsdolphin
Collaborator
Collaborator

@Anonymous

 

Sorry to resurect this all thread but I'm trying to use you code and I keep getting an error.

 

Can you please help me to figure this out?  Here is what I did, I basically copied and pasted your code into a new iLogic rule and changed the URL for the drawing template. When I use it, It creates a drawing with three views but then I get the following error.

 

 ERROR: 

Error in rule: auto-drawing, in document: auto-drawing.ipt

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

MORE INFO:

System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   at Inventor.DimensionStylesEnumerator.get_Item(Object Index)
   at LmiRuleScript.CreateLinearDimension(DrawingDocument oDrawingDoc, DrawingView oDrawingView, DoubleForEquals DimensionLength, String DirectionOfDim, Double OffsetDistance, String DimensionLocation, Boolean ReferencedDim)
   at LmiRuleScript.Main()
   at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
   at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

FYI - The Sheet Metal part I'm trying to create a drawing for is a simple 2 bend L bracket.

 

0 Likes
Message 127 of 134

fsdolphin
Collaborator
Collaborator

@Anonymous

@kylenilsen

Did you ever resolved the issue? I'm getting the same error. Thanks.

0 Likes
Message 128 of 134

Jef_E
Collaborator
Collaborator

Hi,

 

I'm trying to do some drawing automation too but, i'm looking for a way to count all the centerlines that are in a certain view.

 

How can you do this? I can only find drawing curves. But they are not in this collection, they are in the sheet.centerlines.



Please kudo if this post was helpfull
Please accept as solution if your problem was solved

Inventor 2014 SP2
0 Likes
Message 129 of 134

Thomas.Long
Advocate
Advocate

I don't suppose you have a section of code for automatic ordinate dimensions? I have the locations and will have the names of the parts that it needs to dimension to provided in my code, if that helps at all.

0 Likes
Message 130 of 134

Anonymous
Not applicable

Hi This is wonderful. Do you think you could upload your model (if this is not an issue) so that I can refer back to parameter settings?

or you could mail me the model / or transfer using we transfer.

this would be a great.

Thanks

 

0 Likes
Message 131 of 134

Anonymous
Not applicable

Hi, 

on start really good job !! For my not working jet, but no because your code is wrong but because my assembly is not set up for this type of the parameter you using. 

I would like to know if you can just explain to me what is some parameter because "Right_Project" can be exported from part. In part can means length of the part or diameter of the hole, To be honest i just would like to know what is what.  Do you use Attribute helper to set up parameter ? 

 

"Right_Project"

"Horizontal".075, "Top" 

"Horizontal".075, "Bottom" 

"Vertical" 

"Left"
"right"

"Top"

"Chute Front Side:1" + rest of the others

I understand you commented this code a i am should be able to do it but tried.

I think you was use Attribute helper to attach every face or point one parameter to spec. where dimension will start and where will be end.then rest make sense. but what is "d23" "d38" I think that is export from part to assembly and then use in this rule to get value on drawings. I really would like to see it. It is nice program and looks pretty. 

 

 

If you can attach the assembly I can work out by my self. I do understand you do not want to share this sensitive information to every one but if you decide to send me this assembly then kusak.vojtech@gmail.com

I think I can bring some ideas to you I will work on it and I am able to send you back. I just do not wan to write this code again. (btw. do not know how properly)

And also if you not going to help me no problem. I really do understand and just please be honest and send me email with something please.

 

really thank you !   

 

 

 

0 Likes
Message 132 of 134

AMISTRYZ5Q34
Participant
Participant

The code works well, but I was wondering if we could somehow manually input the scale for individual parts right after we say yes on a dialog box?

0 Likes
Message 133 of 134

OliverXL5YM
Contributor
Contributor

Hi! I am trying to use this code to add and remove balloons when parts in my assembly are also suppressed and unsuppressed. But when I unsuppress a part the balloon doesnt show back up. How do I use the code you applied for dimensions for this balloon issue. Thanks!

0 Likes
Message 134 of 134

ngtatsang98
Contributor
Contributor

i ran it but got the following problem can you help me fix it
version I use: 2018
error message : 

Error in rule: Rule0, in document: Frame0001.iam

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
More info:
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.Documents.Add(DocumentTypeEnum DocumentType, String TemplateFileName, Boolean CreateVisible)
at LmiRuleScript.CreateDrawing_PlaceViews(String PartNumber, Double DrawingViewScale, String ViewsToPlace, Boolean AssemblyDrawing, DrawingView& oBaseView, DrawingView& oView2, DrawingView& oView3, DrawingView& oView4)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

0 Likes