make drawing without opening template file

make drawing without opening template file

cadman777
Advisor Advisor
1,279 Views
12 Replies
Message 1 of 13

make drawing without opening template file

cadman777
Advisor
Advisor

Hey Guys, I have a question about making a drawing like when you export to DXF or STEP.

Is there a way to make a drawing with a part file open but not open the idw template when doing it?

In other words, can you do this 'silently' like when you export DXF or STEP (etc.)?

If so, does anybody have any code they can sure on this?

Thanx!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
1,280 Views
12 Replies
Replies (12)
Message 2 of 13

WCrihfield
Mentor
Mentor

Hi @cadman777.  I'm sure there are many ways to do that by code, but this is one of the simple ones I've used in the past.  You can add more details if needed, but this will likely get you started.

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject And _
	ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
	MsgBox("This rule must be ran while a Part or Assembly is active. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
	Exit Sub
End If

'Drawing Template to use - path and file name
oTPath = ThisApplication.FileOptions.TemplatesPath
oTName = "A-Size Standard Drawing.idw"
oTemplate = oTPath & "\" & oTName

Dim oDDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, oTemplate, True)
ThisApplication.CommandManager.ControlDefinitions.Item("DrawingBaseViewCmd").Execute

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡 or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 13

WCrihfield
Mentor
Mentor

Of course though, this simple manual process is just as quick/easy as running a rule like this:

WCrihfield_0-1637766112145.png

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 13

theo.bot
Collaborator
Collaborator

Document.Add alows you to use a template and add it visible or not.

Dim Mydoc As DrawingDocument
Mydoc = ThisApplication.Documents.Add(kDrawingDocumentObject,"D:\Software settings\Inventor\2022\Templates\Standard.dwg", False)


Mydoc.SaveAs("D:\01 Data\Workingfolder Vault\Designs\New.dwg",False)
Mydoc.Close(False)
0 Likes
Message 5 of 13

WCrihfield
Mentor
Mentor

Here is an old one I used to use.  I'm pretty sure I posted this one here on the forum somewhere years ago, but couldn't find the link to it anymore.  It will automatically create 4 scaled views on a new drawing's active sheet of the model that was open when the rule was ran.  There are file names & paths involved in the code though that you will likely need to modify to suit your needs.  I'll just attach the text file, because it's a bit longer than you might like.

 

PS:  The template drawing I was using in this example was in 'landscape' orientation, instead of 'portrait' orientation, so the scaling/orientation of views was planned with that in mind.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 13

cadman777
Advisor
Advisor

@WCrihfield @theo.bot 

Thanks a lot for this info!

Let me 'play with it' for a bit and see how it works and I'll get back to you.

Looks like it was much easier than I thought.

 

My biggest problems is I still can't figure out an easy way to 'look up' the info I need to know to do this.

What I tried to do in the local help was find the SaveCopyAs and see all the settings I can use and get an example or two. But it was nowhere to be found in the local help. And every time I go online to Inventor KB help, it's a struggle to find what I'm looking for. Any ideas how I can streamline this process of finding help when I need it? LOL! I've been asking this question for YEARS now when it comes to iLogic and VBA/.Net. and still haven't figured out a solution to it!

 

Again, thanx for your input!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 7 of 13

cadman777
Advisor
Advisor

OK @WCrihfield, I tried your first rule. It worked, but that's not what I wanted to do. Let me clarify.

I want to make a drawing without opening the template file.

I have a DXF export rule that I got from someone in here (and modified).

From an assembly it exports every single part into a STEP file without opening each part.

I want to do the same thing but instead of exporting each part to STEP, I want to 'silently' create a drawing with a view of the part on it for every single part. One drawing per part.

Hopefully that makes more sense.

Is this possible?

Or do I have to create a drawing for every single part inside Inventor?

If so, for some projects I could end up having 1000 single part drawings open!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 8 of 13

cadman777
Advisor
Advisor

OK @theo.bot, I tried to get your rule to run, but kept getting an error.

But since it's probably like @WCrihfield's rule, I won't worry about it at this point.

Thanx again for offering your help!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 9 of 13

WCrihfield
Mentor
Mentor

OK. I understand now.  Yes, that sounds possible to do by code.  However, drawing automation is one of the toughest tasks to undertake, depending on your needs concerning those drawings.  If all you want is a single page drawing document, with a single view of the model centered on the sheet, and no dimensions, notes, parts lists, balloons, etc, etc, then that might not be so bad.  I don't think I have any pre-existing rules for that task though, because our drawings are way to dynamic for that type of scenario to work for us.  I'm sure that either myself or others here on the forum can come up with something for you though.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 10 of 13

cadman777
Advisor
Advisor

Thanx for your quick reply!

Yes, that's good enough.

Use a template with no border & t/b, and all view label settings already setup, everything in the middle of the sheet. Sheet size irrelevant.

 

Actually, I already have an 'automatic drawing' rule that opens an idw and makes flatpatterns of all parts in the assembly on one sheet. Then I have to re-arrange them and run a few other rules on them, then export it to DXF for the steel mill. I got that rule in here from Sergio S., and modified it a lot to suit my needs. But now I want to output them as separate files. So what I've tried to do is this:

1. open an assembly

2. run the rule on the assembly so it finds every sheetmetal flatpattern

3. and for each part, it creates an idw drawing

4. before it closes that part WITHOUT saving it, it does this:

5. centers the view label @ the view center point

6. saves the file as DXF the way it is, and finally

7. it closes the idw file without saving it.

 

That's my idea of exporting DXF files with the relevant info on them for the steel mill.

Otherwise, I'm going to be damned by being forced back into AutoCAD and re-learn AutoLISP.

No time (or desire) for that!

 

So what I was hoping to find in here is info on the SaveCopyAs idw 'run silent'.

But apparently that doesn't exist, and I'd have to learn how to use ApprenticeServer, which is way over my paygrade!

 

Here is an example of what I'm talking about. That's the same as saying, 'Here's a recipe for making the cake you want. Not all the ingredients are shown, and only some of the mixing proportions, you can use your own oven temperature. And when you're done you can have a lovely, tasty, nutritious cake if you just follow the rules in the recipe.' WTF?? That's nothing short of POLITICAL SUBTERFUGE using psychological warfare techniques. Anyway, I'm beyond the point of frustration when trying to make rules. I've just accepted the fact that we're being HOSED by Autodesk and affiliates and there's a nefarious purpose behind it. It has to do with globalism and power through controlling 'capital and labor'.

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 11 of 13

theo.bot
Collaborator
Collaborator

@cadman777 ,

 

Make sure to run my rule successfully you need to change the path of the template and the path of the save location must exists. I didn't add any checks in this sample ;-). But I noticed that @WCrihfield already helped you in your next steps. Success with your rule creation.

0 Likes
Message 12 of 13

cadman777
Advisor
Advisor

Thanx Theo.

"Make sure to run my rule successfully you need to change the path of the template and the path of the save location must exists."

Yes I did that.

"I didn't add any checks in this sample ;-)"

That's how I do mine until I can get more educated and sophisticated in rule writing!

 

I ended up re-working my existing rule and am on the edge of accomplishing what I want. What remains is to export as DXF with a custom filename (already coded that), and then close the open idw file without saving it (not sure how to do that yet). This next part is going to eat up a good day of 'learning' and trial-and-error 'hacking'!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 13 of 13

cadman777
Advisor
Advisor

Theo,

If you mean I can open the drawing without opening it in Inventor, then that's what I want to do.

If so, can you link me to a good explanation of the syntax of Document.Add where I can see how to do this 'silently'?

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes