AutoCAD Inventor :: ILogic Script To Turn On / Off Text On Drawings
Jun 6, 2012
How to turn on/off text on the drawing? I`m working on the drawing template and would like to have a form that will allow engineer by checking check boxes to turn on/off certain text on the drawing.
I am slowly learning about ilogic, and have created parts and assemblies that are run by rules. My next question is, what exactly can ilogic do for drawings? I've looked at the wikihelp, but I am not a natural at programming and I need more than a list of functions with brief descriptions to get me started.
I'm looking for code snippets, other discussions, tips, tricks, and/or tutorials to get info what I can do with ilogic and the API that can automate parts of the drawing process.
I am looking for a way to create an external rule that will allow me to turn off the visibility of bolt generator items in the model while I am looking at the drawing. Bolts may be buried several subassemblies (4 - 6) deep.
I already have a code below that will read a bunch of drawing filenames that will go into each drawing, save the drawing, (print the drawing but I have this disabled for now,) close it, then move onto the next one.
What I want to do is add reference brackets around every dimension on each drawing. I have managed to update part list styles before using ilogic but I am not sure if it is possible with dimensions.
question = MessageBox.Show("Are you sure you want to update multiple drawings? If so, make sure all drawings are checked out.", "Batch Drawing Update",MessageBoxButtons.YesNo,MessageBoxIcon.Question)
'set condition based on answer If question = vbNo Exit Sub End If
At my company when producing drawings for manufacture we require a sheet for any steel profiles to be cut!..We do this by selecting the assembly from base view,hitting model view tab, selecting presentation and choosing the relevant profile from the drop down!
Once the profile is placed, we highlight the view and hit the parts list tab which obviously creates a parts list, but for the whole assembly, we then have to edit the parts list by turning off the visibility of the lines of all the parts which are not relevant!!...as you can imagine this is quite a laborious task if you have 50 different profiles.
The reason for this is to show the qty, steel grade and part number to the suppliers. My question is, any code that will take the lines of the parts list that are not relevant to the selected view and turn the visibility of those lines off?
I've managed to cobble this code together to turn some sketch visibilities on and off. However, what I'd really like to do is have a single sketch containing some blocks, and turn the visibility of the blocks on and off... How to call the blocks -
'Iterate through the sketches collection'Turn the edging indicators On And Off For Each oSketch In oDoc.ComponentDefinition.Sketches Select Case oSketch.NameCase "Front Edged"If E01 = True Then oSketch.Visible = TrueElse oSketch.Visible = FalseEnd IfCase "Top Edged"If E02 = True Then oSketch.Visible = TrueElse oSketch.Visible = FalseEnd IfCase "Back Edged"If E03 = True Then oSketch.Visible = TrueElse oSketch.Visible = FalseEnd IfCase "Base Edged"If E04 = True Then oSketch.Visible = TrueElse oSketch.Visible = FalseEnd IfEnd SelectNext
Is there a way using ilogic,that when you select/highlight a part within an assembly and run the code that it will turn on the Origin planes only and also turn turn them off ?
I'm trying to finally utilize iLogic and all of its functionality (after using the basic features of inventor for the past 3 or so years) and I was wondering if there was a way to use iLogic (or some other feature for inventor) to resize text in a title block field of an IDW based on the length of the text entered (i.e. if the part's name was "Cam Retainer" the text height would be .12, but if its part name was "Spacer Cam Retainer Bushing" the text height would shrink down to .085 or something) so that it would still fit nicely into the text block?
Can we have a better way to create “text” in the Inventor part drawings?
I almost create “text” in every part drawing in different view. I have to create a sketch first, than create a text and dimension the text so I can lock the text in position, otherwise when you move the view and the text will stay in different location.
I had been used “Solid works” for long times. When I need to create a text, just click that view and create a text and the text will stay with that view, whatever you move that view and the text move together.
I frequently use tolerance and fits when modelling and retreive them to use them in drawings. The text on these dimensions is always horizontal . Any time I have vertical dimension on drawings (e.g. several diameters in a stepped bore) the horizontal text takes up way too much real estate. e.g. 18.0000 g6 (17.999 17.998)
I would like to align the text to the dimension lines (i.e. text vertical in this case) In Properties Rotate is greyed out. Is there a way to keep my retrieved dims and have them aligned with the dim lines in the drawing?
When labeling a view in an Inventor Drawing (Inventor 2012) I want the view identifier label to show but I don't want the scale to appear. Is there a way to turn this off without going into the format text and deleting it every time? When I was using Inventor 2008 it always made me click to turn the scale "on" or visible. Now it does it automatically.
Inventor 2013 Windows 7 Professional 64-bit SP1 HP EliteBook 8470w Processor: Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz Memory: 16 GB AMD FirePro M2000 3D Connexion SpacePilot
Im linking a prompted entry in a sketch symbol to a selection from the user in an array. The code works perfectly.
The array displays the number of sheets there are in the document, the user selects the correct one & the sheet number is displayed in the prompted entry. I need to add "SHT" before the number though in the code but I cant get it to work.
I dont want to add a text line into the symbol saying "sht"
Dim oApp As Application: oApp = ThisApplication Dim oDoc As DrawingDocument: oDoc = oApp.ActiveDocument Dim oSheet As Sheet: oSheet = oDoc.ActiveSheet
'This uses a sketch symbol with the name "'View On' View Label" Dim oSymDef As SketchedSymbolDefinition: oSymDef = oDoc.SketchedSymbolDefinitions.Item("'View On' View Label")
'This is the selected view Dim oView As DrawingView: oView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter,"Select View To Place Symbol:")
'This takes the label items of the selected view 'And adds it To an array that will link To the prompted entry Dim sPromptStrings(2) As String sPromptStrings(0) = oView.Name sPromptStrings(1) = oView.ScaleString
oDoc = ThisApplication.ActiveDocument
Dim sSheet As Sheet
'create sheet number list Dim oSheetList As New ArrayList i = 0 s = "-" For Each sSheet In oDoc.Sheets i = i +1 oSheetList.add(i) Next oSheetList.add(s)
'get user input mySheet = (InputListBox("View taken form sheet number.", oSheetList, oSheetList(0), "Sheet Number Ref.", "Sheet Numbers"))
sPromptStrings(2) = mySheet
'This is the position for the sketched symbol under the selected view' Dim oPosition As Point2d: oPosition = oView.Center oPosition.y = oPosition.y - (oView.Height / 2 + 2.5)
'This inserts the sketched symbol and fills in the prompted entry. Dim oSymbol As SketchedSymbol: oSymbol = oSheet.SketchedSymbols.Add(oSymDef, oPosition, , ,sPromptStrings)
I am trying to enter some material ordering info into an external spreadsheet, and have that info reflected in a text box within an idw drawing file.
My method is as follows:
Obtain a numerical value (250) from an external Excel spreadsheet (sample.xlsx).Assign this value to a parameter (abc) in an idw file (Materials Ordering.idw).Insert parameter abc I made into a text box within the same idw file.
I made a set_parameters rule, and the ilogic text of the above example is as follows:
'Open File and Scan line - Part = Impeller Casing Flange i = GoExcel.FindRow("sample.xlsx", "Sheet1", "Part", "<=", "Impeller Casing Flange") 'abc = Material Width abc = GoExcel.CurrentRowValue("Material Width")
I had no problems with the first two steps, after checking the parameters I could see that parameter abc is being updated successfully.
However, I am having trouble with the third step. In the format text dialog box, I can see a drop box for components, but I can't find a reference to the idw file in there.
My question is, am I going the wrong way about this? Should I have assigned the parameters to a component instead of the idw file?
I have an iLogic that runs to create parts and assemblies. These parts and sub-assemblies are for a range of library components which are either part(s) or assemblies or and assemblies composed of parts) and sub-assemblies as well. This iLogic is mostly done despite I have limited knowledge in this area. At the beginning it opens a text file (.txt) by the command line:
ThisDoc.Launch("L:\_Nov 02Info and Input GuideLines.txt")that offers guidelines and instructions.
I would like to how can I close (exit) this text file at a point within or end of the current iLogic because, it opens a several files of the same every time I run the iLogic otherwise.
Basically we have a number of different procedures that need to be written in each drawing. Each drawing uses one of 5 or so procedures. Usually we type it out every time which is a pain or copy paste. We also tried making word documents and inserting them that way but it got a little buggy. Is there any way to have 5 or so pre made text blocks to pick which to insert onto different types of drawings but that can be global used across a few systems?
We have a small group of workers all on the vault server. Basically I just want to be able to have a finished drawing. Click something that will open a list of my pre made text blocks, and insert one into the drawing that I can scale etc. We use Inventor 2011.
I amrying to create embedding of a text entered through dialog box. The sketch regenerates fine but the Emboss doesn't. Cannot figure it out, tried a lot of different approaches...the text has to be configured this way - need to control it's height.
I am trying to rewrite Curtis Waguespack's ilogic code to modify drawing view labels from this post http: [URL]...
The completed label should appear like this
<Description> - Mk <Part Number> Est Unit Mass = X kg (Scale 1:1)
At this point I have 2 problems
1. I want to add the physical mass to the second line and would prefer to use the calculated physcial property rather than the a custom iproperty. If editing the view label, it would the property access under physcial properties.
2. I want to rewrite the code so it is selective or per view - in otherwords, I only want it to modify a single view I select once the code is run. At this point I know I need to remove the For loop but I dont have a clue as to how to make it selective.
'start of ilogic codeDim oDoc As DrawingDocument: oDoc = ThisDoc.DocumentoModel = ThisDoc.ModelDocumentDim oSheets As SheetsDim oSheet As SheetDim oViews As DrawingViewsDim oView As DrawingViewoSheets = oDoc.SheetsFor Each oSheet In oSheetsoViews = oSheet.DrawingViews For Each oView In oViews oView.ShowLabel = True
I have a lot of pre existing sheet metal parts with my material listed as Steel, Mild.
I am using this code to automatcally fill out my iproperties but the material name is not exactly what I want it to say. iProperties.Value("Project", "Description")=iProperties.Material
I'd like it so that any time it sees Steel, Mild it replaces it with the text "A36"
We have an idw package we use for Quality control. This idw has more than one sheet. Each sheet has a part placed on the sheet with dims.( DWF attached). Next we open DA inside of the file and run a report. (exported txt attached). I am trying to use ilogic the make the same report with a iLogic browser button pick. I have 2 codes (code examples on attached jpg) that i need to make into 1, or whatever works.
1st code Dim oDoc As DrawingDocumentoDoc = ThisApplication.ActiveDocument Dim oSubDoc As Inventor.Document Dim oPropSets As PropertySets Dim oPropSet As PropertySetDim oPartNumiProp As Inventor.Property For Each oSubDoc In oDoc.AllReferencedDocumentsIf oSubDoc.documenttype. [code]....
2nd code fileheader = "QAF Parts for Planning "fileheader1 = ThisDoc.PathAndFileName(True) 'first line header of txt filedescription = "Components to use for Nesting" 'use this variable in the body of the txtdelimiter = "," 'character to separate the names and values on each lineoWrite = System.IO. File. Create Text (ThisDoc.PathAndFileName(False) & ".txt")oWrite.WriteLine(fileheader) 'include the fileheader on the first. [code]....
I'm trying to create an iLogic rule that will print a text string to a cell or coloum of a parts list in inventor.
My code so far...
Sub Main() On Error Resume Next Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument [code]......
I want to print what is in the Message Box into a cell in the parts list, and i am stumped. The cell i am trying to print to is a user property in the Parts List.
My iLogic ability is quite limited outside of what I use regularly?
I am trying to change the font style in every text definition in all my sketch symbols in one go. Actually I have started it based on only a selection set but I would be happy with just all symbols too. Below is where I got to, I am stuck on the For Each line to cover each text box in the symbol. Some of the other syntax may not be right either but I can't test it all the way through.
Dim oDoc As DrawingDocument: oDoc = ThisApplication.ActiveDocumentDim oSheet As Sheet: oSheet = oDoc.ActiveSheetDim i As LongDim oSymDef As SketchedSymbolDefinition: oSymDef = oDoc.SketchedSymbolDefinitions.Item(i)Dim oText As TextBoxesFor i = 1 To oDoc.SelectSet.CountFor Each oText In ............oSymDef.TextBoxes.Item(i).FormattedText ="<StyleOverride Font='ARIAL'>...< /StyleOverride>"NextNextInventorVb.DocumentUpdate()
Also the XML style override is not complete if this is the only way to achieve this result.
Inventor Professional 2013, Autodesk Simulation Multiphysics 2013 Windows 7 x64 Core i7 32GB Ram FX2000
I am using ilogic in Inventor 2011 to update my iproperties when I save a .dwg file. I am having problems with some custom iProperties I have created that are of the type 'number' and are initially set to 0 (zero). After the iLogic rule has run and the user has entered a numeric value the type of the custom iproperty has changed to 'text'.
The ilogic code I am using is:
If iProperties.Value("Custom", "Nominal ID") = 0 Then iProperties.Value("Custom", "Nominal ID") = InputBox("Enter The Nominal ID (Enter 0 if no value is available)", "Nominal ID", 0) Custom_iProp_Nom_ID = iProperties.Value("Custom", "Nominal ID") End If
I am using Vault 2011 and would like to map this property to a numeric property so I can perform <= and >= searches.
I had wanted to find a way to engrave/emboss the part number on a part model and have it be parametrically tied to the part number iProperty. Since it doesn't appear that I can create a text box and insert the iProperty directly, here's what I did to work around this. (I setup my part templates to have this out of the box....)
1. Within, the IPT file, add a user text parameter called "PartNo" and set its initial value to any text value.
2. Create your sketch for your text to be engraved. Insert the User parameter you just created.
3. Create the engraving/embossing for your text.
4. Create the following iLogic rule:
' Requires a User Text Parameter called "PartNo" prior to running' Set the appropriate event trigger to tasteIf Parameter("PartNo") <> iProperties.Value("Project", "Part Number") ThenParameter("PartNo") = iProperties.Value("Project", "Part Number")InventorVb.DocumentUpdate()End If
5. I set this rule to fire using the "iProperty Change" event trigger. So if the iProperty is set or changed, your text will update. Obviously, you can set this to run with whatever trigger you like.
I'm trying to create an iLogic rule that will print a text string to a cell or column of a parts list in inventor.My code so far...
Sub Main() On Error Resume Next Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument [code]...
I want to print what is in the MessageBox into a cell in the parts list, and i am stumped.The cell i am trying to print to is a custom property in the Parts List.