Hi,
I have a drawing that can be used to manufacturing purpuses or to normal company ipt, iam, etc., and I want to when opening a new drawing configure it if the designer if it chooses yes in the msgbox change the title bock and the standards in the styles.
started the code like this:
Dim i As String i = MessageBox.Show("Vai efectuar o desenho de uma ferramenta ou de um elemento seu?", "Parts List", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) If i = "6" Then ActiveSheet.TitleBlock = "Alualpha_Ferr" End If
but it gives this error
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
sorry but I'm a beginer 🙂
Thanks in advanced
FG
Hi,
Instead of a message box pop up, I have a form that pops up once the template drawing is opened.
Use attached image as reference
black box shows my title blocks
red box shows my custom styles which controls my drawing units
arrow point to rules used.
This form allows me to choose
and the form is started using the rule with purple arrow
disregard all company info and logo's
Good Luck!!
Hi laptop_geek,
I put the if because if the designer click yes, the msgbox gives i = to 6 so if the designer says yes it will change the title block and after change the standard... But the standard I didn't start at alll
and my code is what I presented loool sorry if it is so simple but i thouht it would be enough
Thanks
Hi SeanFarr,
It seems that you have the code I need to start doing something but my inventor is 2012, can you save in that version and put again... I know it can lose properties by saving in a older version but if I take a peak maybe I can make my work.
Thanks
I think I understand it now. I tried your code and it worked fine for me. The only thing it does is change the title block though, If you want it to change the styles too it will take a little more code.
Here is the meat of the macro that we wrote to change the styles for our templates.
Private Sub ASSEMBLY_DRAWING_Click() Dim oDoc As DrawingDocument Set oDoc = ThisApplication.ActiveDocument oDoc.StylesManager.ActiveStandardStyle = oDoc.StylesManager.StandardStyles("Assembly Drawing Style") End Sub
sorry laptop_geek but i've pasted your code and it gives me back error... i've putted on itriggers, don't know how to work in macros...
So for each of these rules, make sure there is a multi-value text parameter with the proper names that match the rule
Here is rule for changing sheet size:
Dim drawingDoc as DrawingDocument = ThisDoc.Document 'A size If Sheet_Size = "A (8 1/2 X 11)" Then ActiveSheet.ChangeSize("A", MoveBorderItems := True) 'B size ElseIf Sheet_Size = "B (11 X 17)" Then ActiveSheet.ChangeSize("B", MoveBorderItems := True) ''C size ElseIf Sheet_Size = "C (17 X 22)" Then ActiveSheet.ChangeSize("C", MoveBorderItems := True) ''D size ElseIf Sheet_Size = "D (22 X 34)" Then ActiveSheet.ChangeSize("D", MoveBorderItems := True) ''E size ElseIf Sheet_Size = "E (34 X 44)" Then ActiveSheet.ChangeSize("E", MoveBorderItems := True) End If 'update all InventorVb.DocumentUpdate() 'zoom all ThisApplication.ActiveView.Fit
and it uses these parameters:
rule used for changing standard:
To use this rule, create a Text parameter named Standard in the drawing. ' Assign it values such as: ' ANSI ' ANSI-mm doc = ThisDoc.Document customPropertySet = doc.PropertySets.Item("Inventor User Defined Properties") 'Make sure drawingUNITS property exists Try prop = customPropertySet.Item("drawingUNITS") Catch 'Assume error means not found customPropertySet.Add("", "drawingUNITS") End Try Dim drawingDoc as DrawingDocument = ThisDoc.Document For Each standardX In drawingDoc.StylesManager.StandardStyles Dim internalName As String = standardX.InternalName Do Trace.WriteLine(" -- internalName = " & internalName) Dim ch As Char = internalName(internalName.Length-1) If (ch <> vbCr And ch <> vbLf And ch <> ")" And ch <> " ") Then Exit Do internalName = internalName.SubString(0, internalName.Length-1) Loop Trace.WriteLine(String.Format(" Style: {0}, {1}", standardX.Name, internalName)) If (internalName.EndsWith(Standard, StringComparison.OrdinalIgnoreCase)) Then drawingDoc.StylesManager.ActiveStandardStyle = standardX Trace.WriteLine(" --- Changed the active drawing standard to " & standardX.Name & "...") Exit For End If Next iProperties.Value("Custom", "drawingUNITS") = Standard InventorVb.DocumentUpdate() Exit Sub handleErrors: 'do nothing
it is important that this parameter also match the actual standard names in your styles manager library:
now here is the rule for changing the title block:
Dim drawingDoc as DrawingDocument = ThisDoc.Document If Title = "ELECTRICAL - A" Then ActiveSheet.TitleBlock = "ELECTRICAL - A" ElseIf Title = "ELECTRICAL - B" Then ActiveSheet.TitleBlock = "ELECTRICAL - B" ElseIf Title = "EQUIPMENT - A" Then ActiveSheet.TitleBlock = "EQUIPMENT - A" ElseIf Title = "EQUIPMENT - B" Then ActiveSheet.TitleBlock = "EQUIPMENT - B" End If 'update all InventorVb.DocumentUpdate() 'zoom all ThisApplication.ActiveView.Fit
and here are my title block parameters:
so basically, your should be able to use these rules, apply it to a form or somehow to a message box and get the result. Just swap out my parameter names to something that is more for your use.
I too have very little programming knowledge, but with the help of some others and searching this forum i was able to create my template.
I don't have 2012 installed so these screen shots will have to do...post back if you need help...some one will reply...
good luck!!
Dim oDoc As DrawingDocument oDoc = ThisApplication.ActiveDocument oDoc.StylesManager.ActiveStandardStyle = oDoc.StylesManager.StandardStyles("Style For Alualpha_Ferr")
Here is the code that will change the styles in iLogic. Simply copy and paste this into an iLogic rule, chagne the "Style For Alualpha_Ferr" to the name of the style you want to use, then run the rule. It will change the style to whatever the "Styler For Alualpha_Ferr" text is changed to.
Thanks by the quick response as with your help the standard style is already changing but the title block still gives me an error.
here's the code:
Dim i As String i = MessageBox.Show("Vai efectuar o desenho de uma ferramenta ou de um elemento para uma?", "ALUALPHA", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) ' mudar os estilos If i = "6" Then Dim oDoc As DrawingDocument oDoc = ThisApplication.ActiveDocument oDoc.StylesManager.ActiveStandardStyle = oDoc.StylesManager.StandardStyles("Alualpha Ferramentas") End If ' mudar os title block If i = "6" Then Dim drawingDoc as DrawingDocument = ThisDoc.Document ActiveSheet.TitleBlock = "Alualpha_Ferr" End If 'actualizar InventorVb.DocumentUpdate()
and the error is:
The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
And what it does is deleting the current title block and not inserting what i've putted... any ideias....
does your title block have prompted entries?
I had this issue and it was because I had prompted entries.
If you use this snippet
ActiveSheet.TitleBlock = "My Title Block"
with prompted entries then you will receive an error
but if you use this snippet:
ActiveSheet.SetTitleBlock("Other Title Block", "promptedEntry1", "promptedEntry2")
it might work?
Good Luck!
yes I'vebeen looking in the forumsand just putted that without text but now it does not shoes the prompt entry dialog..... ddaaammm it loool
Dim i As String i = MessageBox.Show("Vai efectuar o desenho de uma ferramenta ou de um elemento para uma?", "ALUALPHA", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) If i = "6" Then ' mudar os estilos para ferramentas Dim oDoc As DrawingDocument oDoc = ThisApplication.ActiveDocument oDoc.StylesManager.ActiveStandardStyle = oDoc.StylesManager.StandardStyles("Alualpha Ferramentas") ' mudar os title block ActiveSheet.SetTitleBlock("Alualpha_Ferr", "", "", "","","","","","","","") End If
What do you think? how can i show the prompt entry dialog?
Dim i As String i = MessageBox.Show("Vai efectuar o desenho de uma ferramenta ou de um elemento para uma?", "ALUALPHA", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) If i = "6" Then ' mudar os estilos para ferramentas Dim oDoc As DrawingDocument oDoc = ThisApplication.ActiveDocument oDoc.StylesManager.ActiveStandardStyle = oDoc.StylesManager.StandardStyles("Alualpha Ferramentas") iLogicForm.Show("Add Prompted Text") ' mudar os title block ActiveSheet.SetTitleBlock("Alualpha_Ferr", PText1, PText2, PText3,PText4,PText5,PText6,PText7,PText8,PText9,PText10) End If
Create a parameter for each of your prompted text entries (call them PText1, PText2, etc. unless you change the names of the parameters). Then make an ilogic form and place each of the prompted text parameters into that form. Rename the "Add Prompted Text" in the sample iLogic code to whatever you call the iLogic form and you should be good to go.
it's ok, but now i've noticed that in the title blocks I had a campany logo as image (not linked) and when ilogic place the title block the logo vanish....
Any ideias???...
TIA
how many title blocks do you have?
you might have to edit each definition and re-add the logo to each?
sidenote: it is hard to tell what is wrong with your posts...need to add screenshots or even attach your files...
Good Luck!
Hi,
I have two title blocks...
- Alualpha
- Alualpha_Ferr
any others you see don't matter.
Thanks
I don't have your logo but did you retry embedding your logo into the title block definition where is doesn't show?
The logo appears in the Alualpha when you edit the definition, but it doesn't show up in the Alualpha_Ferr definition.
I am not sure why, but your company logo was not showing up in Alualpha_Ferr,
so i edited the definition, delected the logo that was transparent, re-embeded logo (not linked), and saved template.
and it works for me...i can attach the template file, but i use 2014, don't have 2012.
Here is the image:
Can't find what you're looking for? Ask the community or share your knowledge.