Inventor Customization

Reply
*Expert Elite*
mrattray
Posts: 2,450
Registered: ‎09-13-2011
Message 21 of 121 (1,807 Views)

Re: iLogic Coding to Create Automated Drawing

03-20-2012 10:29 AM in reply to: mehatfie

You can't just shove an extra enum in there. He was probably trying to do the same thing as you and then found out he couldn't. He should have deleted that dingle berry out before publishing it.

 

Remember that everyone on the internet knows everything and if someone can post on a forum everything he does is perfect.:smileyhappy:

Mike (not Matt) Rattray

Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 22 of 121 (1,799 Views)

Re: iLogic Coding to Create Automated Drawing

03-20-2012 12:02 PM in reply to: mrattray

Unfortunate that it's not that easy :smileywink:

 

Now I'm trying to save the drawing as I'm trying to run the rules inside of my template automatically

 

I need to find out how to save the document and the closing it will be pretty much the same I assume

*Expert Elite*
mrattray
Posts: 2,450
Registered: ‎09-13-2011
Message 23 of 121 (1,795 Views)

Re: iLogic Coding to Create Automated Drawing

03-20-2012 12:12 PM in reply to: mehatfie



ThisDoc.Document.Close

 This will save and close the document.

ThisDoc.Document.Close(False)

 This will close without saving.

 

ThisDoc.Document.Save

 This will save without closing.

 

 

ThisDoc.Document.SaveAs(filePath & "\" & fileName & ".idw" , False)

 This does a save-as without closing. This is copy/pasted out of a sub that I'm using it in where filePath and fileName are strings that hold the obvious information. In other words there are earlier in the code several lines like the following:

Dim filePath As String
Dim fileName As String

filePatch = "C:\temp"
fileName = "temp"

 You could also just replace that garble with a regular line of text like: "C:\temp\temp.idw"

I don;t remember what he False is for and it's time for me to go home.

 

Mike (not Matt) Rattray

Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 24 of 121 (1,793 Views)

Re: iLogic Coding to Create Automated Drawing

03-20-2012 12:38 PM in reply to: mrattray

I figured out how to Close the document which is similar to the "ThisDoc" command except it's not ThisDoc as the rule is being run in the assembly but I want to control the Drawing Document which technically doesn't exist yet as it hasn't been saved.

 

I learned to use the Object Browser to a little more extent, it looks like I have to use this

"DrawingDocument.Save2([SaveDependents As Boolean = True], [DocumentsToSave])"

 

I can't figure out what this DocumentsToSave means

 

Thanks for your help though

Mitch

Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 25 of 121 (1,791 Views)

Re: iLogic Coding to Create Automated Drawing

03-20-2012 12:48 PM in reply to: mehatfie

I've now Saved the Document by doing a SaveAs instead as I can actually figure out how to do this, and once I open this document shortly after the SaveAs my rules trigger. So everything seems to being flowing as I want it to unless there is a better way of coding it.

 

All I need now is to figure out how to get those 4 options set in the view

 

Thanks

Mitch

Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 26 of 121 (1,783 Views)

Re: iLogic Coding to Create Automated Drawing

03-20-2012 01:38 PM in reply to: mehatfie

I'm not very good at posting my questions in one message...

 

As I am waiting to figure out how to set those view options, I'm looking into attempting to dimension the views.

 

Looking at the API, I had trouble trying to use the "Add Linear" for "GeneralDimensions". I'm sure that I filled out one of the sections wrong in the brackets but I can't figure out which one. I tried to use "kStartPointIntent" and "kEndPointIntent", but I don't understand how they would know what to select.

 

Moving on after trying that, I'm now looking at the "GetRetrievableDimensions" in "GeneralDimensions". I do not know what the code wants from me when it asks for the "ModelObject"

 

I inserted "Add" into this location where it asks for "ModelObject" and I get this error which I'm assuming means that I'm using the API improperly

 

 

Error in rule: Rule21, in document: Rect_Transition_Chute_Generator.iam (MASTER iLogic Assembly)

Public member 'DrawingDimensions' on type '_DocumentClass' not found.

 

Thanks Again

Mitch

Employee
MjDeck
Posts: 957
Registered: ‎02-24-2009
Message 27 of 121 (1,776 Views)

Re: iLogic Coding to Create Automated Drawing

03-20-2012 08:13 PM in reply to: mehatfie

Mitch,

 About the options to create the view initially:

The Level of Detail will be taken directly from your model document.  If you activate the LOD that you want before running the rule, that's the LOD that will be shown in the drawing views.

 You can add the View Representation name to the function to create the base view:

oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, 3/16,kFrontViewOrientation, kHiddenLineDrawingViewStyle, "Default")

It looks like the API doesn't provide a way to specify the options for reference components when you create a view:

Line Style = "As Parts"

Hidden Line Calculation = "All Bodies"
DrawingViewReferenceData.png

 

About the dimension error: are you looking for a DrawingDimensions object directly on the Document?  It's on the Sheet instead:

oSheet.DrawingDimensions

 

 Again, I would recommend using VBA or VB.NET to develop this code.  It might take you a while to get started, but it will save you time in the long run.



Mike Deck
Software Developer
DLS - Mechanical Design
Autodesk, Inc.

Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 28 of 121 (1,768 Views)

Re: iLogic Coding to Create Automated Drawing

03-21-2012 05:53 AM in reply to: MjDeck

Thank for the help Mike, I'll give it a shot and see if I can find a way around those options.

 

I will try to do it in VBA, the only issue is that I don't have "time" to learn the code in depth in order to do what I like. But, nop harm in giving it a shot.

 

Thanks

Mitch

Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 29 of 121 (1,736 Views)

Re: iLogic Coding to Create Automated Drawing

03-26-2012 10:59 AM in reply to: MjDeck

Hello and welcome to Monday :smileytongue:

 

In doing some more reseach and making the changes that Mike suggested with a few extras of my own, the code and drawing have improved.

 

With the research I have found a way to place dimensions but the suggested way is only possible by manually pre-selecting the line then running the vba code. This worked and placed the dimension, and I understand how to manipulate this code to change the type of dimension as well as where it is placed.

 

But as you know, I do not wish to manually pre-select the line. Through more looking around a found a user who was looking to apply centerlines in views (which I will also need to do later on).

 

One of the suggested methods is to use the "ModelEdge" object. I looked in the object browser and did not find anything their myself but I could be missing something.

 

To me, this sounds to be exactly what I'm looking for. If I can pre-select the line by programmically calling the model edge I wish to dimension, I can run this code that dimensions the selected line.

 

You can find the code so far attached

 

The commented line "oCurve = oDrawDoc.SelectSet(1).Parent" is what was used to get the manually selected line

 

Here is the Centerline forum, Message 13 is the reference:

 

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/Add-Centerlines-through-VBA/td-p/30897...

 

Thanks
Mitch 

Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 30 of 121 (1,728 Views)

Re: iLogic Coding to Create Automated Drawing

03-26-2012 11:29 AM in reply to: mehatfie

I just realized some numbers in that code may look a little weird.

 

I use a drawing template that I've put existing codes into like this one which resizes the view and places them where I'd like.

 

I've also tried this as a test but it does not work and an error comes up once it hits this portion of code. See attached "Test Code" 

 

Thanks Again

Mitch

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube