AutoCAD Inventor :: VBA Code That Allow To Get Filename From Border Of Drawing
Aug 10, 2012
I need some VBA code that will allow me to get the Filename from the border of a drawing. I've got code to get to the text of the filename, but I need to get the filename itself. Hope that males sense. Here's the
Public Sub GetModelFilename()
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
[Code]...
What the code returns is the text <FILENAME>. What I need is the filename itself.
View 8 Replies
ADVERTISEMENT
Oct 22, 2013
I've inherited the AutoCAD management at my office and I'm struggling a bit with my title border. We're in the process of moving from Mechanical 2012 to Mechanical 2014 and while setting up the new template I seem to have caused a problem with our title block - the file name no longer auto updates each time you save, where it did in 2012.
I have set the Options > AM: Preferences > System > Acad/M > Title > TitleUpdate variable to 1, but still no luck.
The file name attribute has the following info:
Tag: GEN-TITLE-DWG
Prompt: File Name
Default: (blank)
Are there any other options I need to change to get this to work in Mechanical 2014?
Edit: looks like it does update, but only when you open the file. ie. you need to save, close, then re-open the dwg. how to make it update when saving like it did in 2012?
View 1 Replies
View Related
Feb 27, 2012
We have about 1000 drawings with VBA code that copies information from the title block into the drawing file custom properties. We have done this to get the information into a ACAD block to meet our clients requirements. It is an autosave routine so it runs whenever the file is saved in Inventor. We would like to make a change to the VBA code so we need to replace the autosave routine in the file with another.
Manual steps are:
Open the file
Enter VBA editor
Delete the autosave routine (without exporting)
Import the new autosave routine
Exit the VBA editor
Save and close the file
I'm sure we would write a routine to do this. However the effort from scratch may be more that just manually processing the files.
Currently running IV 2010.
View 2 Replies
View Related
Jun 2, 2013
I have found some code which extracts the part number from the iproperties of a model and adds it to the custom iproperties of a drawing but this will only work on iam or ipt files.
Here's the code, I added the lines referring to the docment type as an attempt to fix the error but it didn't work...
If (ThisDrawing.ModelDocument Is Nothing) Then ReturnIf ThisDrawing.ModelDocument.DocumentType = kPresentationDocumentObject Then modelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)End IfIf
[Code]....
View 2 Replies
View Related
Jun 10, 2013
I am building a custom batch update for our drawings to take border definitions as well as custom iproperties from a current template and push them into a specified inventor dwg file. I built a form for the users to select the template they want to import into a list of files they place in the form. The program opens the template, get's all the information (iproperties, border defs, etc... using the active document to get the document) then iterates through the list of the users doing the following for each file (also getting the active document to get the items in each file): open, replace border definition, insert any non-existent custom iproperties, save and close the file. It works great when I keep the open visible set to true for the files. When I switch the visible property to false for each one of the files I want to open I get an error similar to this: Systems.InvalidCastException: Unable to cast object of type 'Inventor._DocumentClass' to type 'Inventor._DrawingDocument'. at ---- then my button click event here.
Does inventor technically not see a document as an active document if the file is not visible when opened?
View 2 Replies
View Related
Aug 27, 2011
How to change the color of layer that will be used within a drawing files for special purposes.
Ideally the code will make the color Red, but change to Black prior to printing.
The "logic" behind the code currently is to differentiate a layer called "Burn" to a highly visible color for the purpose of review by others then, prior to printing, change the color to Black. The firm I'm currently working for uses gray-scale B sided printers only. The firm currently uses Blue for dimension and extension lines so to produce drawings that portray both type of objects "lightly".
View 2 Replies
View Related
Feb 20, 2012
The company I work for produce drawings for various types of fabrication.
Using Inventor I have a drawing border in which tolerance values change depending on the type of fabrication to be produced. The type of fabrication (0,1,2,or 3) is designated by a custom property entered during part/fab model creation.
This property may change depending on various production factors. The issue I have is how do I get the border to recognize this potential change in fab type and populate the tolerance fields with the necessary information?
View 3 Replies
View Related
Feb 15, 2013
At my company we use part numbers as file names for everything. for example, part number 09090P00100000, will be saved as 09090P00100000.ipt and will have a drawing saved as 09090P00100000.idw.
Within the drawing template file, i want to set up an ilogic rule that will check that the part present in the drawing corresponds to the file name of the drawing. This rule will run after saving and will just display a warning if the file names do not correspond.
I just need some code that will get the file name of the part displayed in the drawing. Note that we use iparts so the code must get the member file name and not the factory file name.
Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDrawingDoc.ActiveSheet
[Code] ........
Autodesk Inventor Professional 2011
Windows 7 Enterprise, 64-bit
View 8 Replies
View Related
Jul 31, 2012
I'm having real difficulties getting my drawing borders to work between Inventor and AutoCAD. I am using Product Design Suite 2012.
I have created a drawing border using Inventor, which is the template for any drawings I produce. I often export the Inventor drawings into AutoCAD 2007 dwg's to send to customers. However, it seems all the text goes up the creek after the export...
When I open the exported AutoCAD drawing, first I explode the drawing border. Then, if I scale the border from within AutoCAD, none of the text wants to scale up. - I've attached the border. I've tried several different ways to fix it using text styles, heights (setting to 0) etc and still no luck!
How to fix the text scaling?!
View 1 Replies
View Related
Nov 13, 2013
What is the proper syntax for removing a bmp file inserted into a drawing border defintiion? I am using VB.net.
I got all the way into editing the sketch of my border defintion...
I know the name of the sketch image I want to delete it's something like "C:Temp12345678.bmp"
So I wanted to use the name to get the image file and set it to a variable. Then run the .Delete() command on that. But it's not working.
This is what I have, where oCSTicBorderDef is equal to the border defintiion of the active document..
Dim oSketch As DrawingSketch
oCSTicBorderDef.Edit(oSketch)
Dim strImageDirectory AsString
[Code].....
View 1 Replies
View Related
Nov 11, 2012
I have a drawing that has a white background.
I would like to add more to the white background to make it bigger without having to stretch it and distort the image.
I want to place a circle shaped outline border around the original image with a set border thickness and color and be able to crop/remove the portion of the image beyond the outline, changing it from a square/rectangle image to a circular image.
If I am not able to change the drawing to have a round outer border from square, how can I make the outer parts past the newly created circular outline transparent?
View 6 Replies
View Related
Apr 18, 2013
I have just installed AutoCAD 2006 on a new PC, and for a while everything seemed fine. However when I save a drawing it comes up with the following:
Unable to save to drawing (path and filename).
Drawing saved to (path)savAE01.tmp
It allows me to saveas without a problem.
If I come out of AutoCAD and try to open the file I attempted to save, it is visible in the file list, but a message pops up saying:
Cannot find the specified drawing file. Please verify that the file exists.
I can rename the .tmp file to a .dwg file and it opens, but then if I try to qsave it, the same thing happens.
View 3 Replies
View Related
May 10, 2013
I am trying to write code to collect standard info from a csv file to be added to iProperties.
Following is the code I have so far.
Dim Separators() As Char = {""c} Words = ThisDoc.Path.Split(Separators) FilName = "C:VaultDesigns" & Words(3) & "Spec_Sheet.csv"
Dim ReadCSV As New System.IO.StreamReader(FilName) Dim WordSets As New ArrayList()
Do While ReadCSV.Peek <> -1 WordSets.Add(ReadCSV.ReadLine.Split(",")) Loop
i = 0 SName = iProperties.Value("Project", "Stock Number")
For Each wrd In WordSets If WordSets.item(i)(0) = SName Then iProperties.Value("Project", "Description") = WordSets.item(i)(1) iProperties.Value("Custom", "Finish") = WordSets.item(i)(2) End If i += 1 Next
The only problem I have is that this line crashes. I am not competent enough to understand why.
Dim ReadCSV As New System.IO.StreamReader(FilName)
View 3 Replies
View Related
Nov 8, 2006
Is there a way to use the filename to drive the parameters of the file?
Example: I have a cube that is called 4x4x4.ipt its dimensions d0,d1,d2 are 4,4,4 respectively. I want to rename it to 4x4x6.ipt and have the dimensions d0,d1,d2 resize to 4,4,6.
View 9 Replies
View Related
Dec 17, 2013
I'd like to change the filename of a part before it's first save.The code would look somewhat like below.
Private Sub m_appEvents_OnNewDocument( _ByVal DocumentObject As Inventor._Document, _ByVal BeforeOrAfter As Inventor.EventTimingEnum, _ByVal Context As Inventor.NameValueMap, _ByRef HandlingCode As Inventor.HandlingCodeEnum) _Handles m_appEvents.OnNewDocumentDim oDoc As Inventor.DocumentDim Name1 As String = "New Filename...."oDoc = DocumentObjectoDoc = oDocoDoc.PropertySets("Design Tracking Properties").Item("Part Number").Value = Name1oDoc.DisplayName = Name1oDoc.FullFileName = Name1.
The code partly works when opening a template but doesn;t work when create a an in place component or frame generated part? What do I need to modify to catch and change the filename before it's saved?
View 1 Replies
View Related
May 13, 2011
Is that possible to get the current Project number and Drawing by using some vba code?
View 2 Replies
View Related
Apr 4, 2013
Is there any possible way to enter a G Code into AutoCAD to end with the result of a 2D drawing of what my CNC has made? I have the code from the machine, and am not sure how to input it into the program to draw the face the CNC has cut out.
View 9 Replies
View Related
Apr 27, 2012
I am using this code snippet to open an idw. With this code, the idw has to reside at the same file path as the current document.
>>>>>>>>>>>>>>>>
Sub OpenIDW()
On Error GoTo Oops
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
Dim sFullFileName As String
sFullFileName = oDoc.FullFileName
Dim sDrawingName As String
sDrawingName = Left(sFullFileName, Len(sFullFileName) - 4) & ".idw"
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.Documents.Open(sDrawingName)
Exit Sub
Oops: MsgBox "IDW File could not be found. FileName of IDW must be the same as this file.", vbInformation End Sub
>>>>>>>>>>>>>>>>>
"What if"... my idw is not at the same location, but under a subfolder instead..... like this
Part file c:designsDrawingsJobxxx
Idw file c:designsDrawingsJobxxxIDW
I am sure that this can be done by editing the line "sDrawingName = Left(sFullFileName, Len(sFullFileName) - 4) & ".idw" " . Everything I have tried did not work.
View 3 Replies
View Related
Jun 6, 2013
I'm attempting to create a rule using iLogic, which reads the first two letters of either the File Name or Part number (Which ever is easier)i.e. if a part number was AB12345, I would want the code to recognize the "AB"...At which point I'm trying to use an If-Then-Else statement to modifiy the material of the part, dependent on the first two characters of the File name.
As an example, where the underlined portion is what i don't know how to
If iProperties.Value("Project", "Part Number") Begins with "AB" Then
iProperties.Material = "Steel"
Else If iProperties.Value("Project", "Part Number") Begins with "AC" Then
iProperties.Material = "Aluminum"
End If
View 1 Replies
View Related
Oct 13, 2011
I am trying to use the iProperties.Value("part1", "Summary", "iProperty") function to get the filename or complete filepath of a component within a subassembly. I know that these iProperties exist because I can insert them onto a drawing, and I see them in the general tab of the iProperty window.
However, when I try something like:
filename = iProperties.Value("part1", "General", "Filename")
I get an error message indicating that the General tab can't be found. How might I go about getting this filename iProperty, or is there an easier way?
View 4 Replies
View Related
Jun 8, 2012
I have VB code that loops through and utilizes Excel data to pick which file(s) to open, update, and close. Then it opens the appropriate .idw file, updates it and saves it as a .pdf.
The line of code I have now is simple:
_invApp.ActiveDocument.SaveAs("C:UsersxxDesktopA60.pdf", True)
and that writes the file to my desktop as a .pdf.
However, as the loop runs over and over, it will find another data set that is the same A60 type, so it will want to save OVER that .pdf it's already created.
How do I go about having a variable filename? Something where it would add a _01 _02 _03 (or similar) to the end of the filename (i.e. A60_01.pdf, A60_02.pdf).
View 1 Replies
View Related
Feb 6, 2013
I have an assembly which serves as a configurator. This Assy, needs to be copied many times. The assy contains 2 parts, which also must be copied. but when copied, the parts must have a new filename, and then the Rule cannot find them anymore. Therefore my plan is to define the filename with the configurator rule..
Example.:
Assy = Module.iam
Part1 = Module-1.ipt
Part2 = Module-2.ipt
I have this so far, but is doesn't work.. what do i put before the .ipt??
Filename = ThisDoc.FileName(False) 'without extension[Filname-1 inserted here].ipt.Diameter = "30"
View 9 Replies
View Related
Oct 15, 2010
I need simple code to do just one thing, inserting a dynamic block that is stored in a separate file on my computer (like C:/base/b-22) in the drawing that I'm currently using. For example, I have a windows form with a list box with names of many dynamic blocks that are stored on my c drive, I would like to pick a block with a name and upon a click event of a button or other will go get this block from a separate file and insert it in the drawing I'm currently using, and would need to be able to pick the point of where I want the block to go. I'm using autocad 2010 with visual studio 2008- using the new autocad .net language.
View 9 Replies
View Related
Jun 21, 2013
I am trying to make a button such that if the user clicks it, AutoCAD will automatically draw a border that just includes all entities in the drawing.(Something) like the viewport border in the paper space)
Approach #1: The first approach could be zoom extent and draw a border around the zoomed view. how to zoom extent and draw a polyline, but can't figure out the exact size of zoomed view.
Approach #2 (optimal) : If the entity is a right circle and my AutoCAD window is not in square shape (for example, the AutoCAD window is maximized and my monitor is wide-screen monitor), Approach #1 will create redundant spaces at the right and left side of the circle entity. So if I could get the grid coordinate of far left, far right, top, and bottom entities, I can draw the optimal border around all entities in the drawing.
View 9 Replies
View Related
Mar 10, 2012
I am trying to create a set of drawings to a standard and need to be able to create a border for them. I have tried creating a border in a layer, but it needs to be 5cm from the edge of the page.
View 1 Replies
View Related
Oct 24, 2011
Want to create a drawing border, a box on the right hand side containing all the information about the drawing. I want this to be a template so each drawing I create will have the drawing border on the right.
View 6 Replies
View Related
Nov 8, 2011
Create a Content Center Part that prompts for a file name and sets the Part Number to whatever I save the part as? It would also be nice to... Have the browser Display name the same as the saved filename.
If I have a standard part with a blank filename, inventor will make the part number equal the filename at the first save. It is this functionality that I require when using Custom Content parts.
E.G. If I have a length of 'RHS 200x100x6.3 - 2000mm' selected from content centre and I want the filename to be saved as 'Part-001', then I would like the Part Number to be set as 'Part-001'.
If I then place the same member in another project/assembly I may want to call it 'ProjectPart-100', where the part number would then be 'ProjectPart-100' and so on.
This method ignores the filename entry in the Ipart table.
View 1 Replies
View Related
Nov 30, 2011
"The filename, directory name or volume label syntax is incorrect. The database in K;lah/blahlah.widget.ipt* could not be saved".It's nothing to do with an improper name; even saving as the default 'Part 3' doesn't work.
At the moment I'm limping by using Save Copy As. Neither Save not Save As work at all.
View 3 Replies
View Related
May 14, 2012
An application that will let me choose a group of Drawing files (.idw) and perform "Save Copy As" to a PDF format on them. The Filename of each Drawing should be extracted from a custom Parameter I embeded in the IDW file.
I know I can use the Task Manager with a virtual PDF Printer to create these files, but then the PDF Filename will equal the IDW Filename, and I want it to be derived from the custom parameter I prepared inside the drawings.
View 2 Replies
View Related
Oct 9, 2013
When using save copy as to make an identical part with a different number, the file name in the top and the browser doesn't update to the new filenumber. only in the bottom file tabs is the name correct. if I go to file> save as I can also see the new filename. This is a hassle when doing this to multiple files in an assembly, as it makes it hard to keep track of which parts have been given a new name. It seems the filename input in the browser is only written once, and that is when the first file was saved for the first time.
View 7 Replies
View Related
Dec 14, 2012
When I publish from Inventor to DWF (including sheets in the idw and an view of the iam assembly file) numerous part properties are included in the dwf that I would like to strip out so we don't share too much info with.
For example, filenames are included, stock numbers the complete bom from the model (as opposed to the parts lists that are shown in the idw's... This info shows in the structured bill, and if you click on a part in the iam.
How do I filter all this out so I only show part numbers and descriptions in iproperties?
View 4 Replies
View Related