Hello,
i want to use pictures with my forms and was wondering if i can use them like the way i showed in attached image.
the CaseA image is the one i can currently use and CaseB is the way i want to use. My reason to do this is, i have alot of parameters to change and having both the picture and a menu below/above takes alot of space which also seems redundant.
Solved! Go to Solution.
Solved by mrattray. Go to Solution.
There's no way that I know of to do that with the current editor. You can, however put the parameters all to the left or right of the image using the "Row" control.
The only way you can get parameters imbeded into an image like you have shown would be to use the API to create a custom form using straight VBA. This isn't difficult if you're familiar with that environment, but if not then it may be more work then it's worth.
Mr. Rattray
Thx for the reply.
I've used VB way back, during university years. I don't remember much to start on my own again. Can you advice a beginners book maybe? Or some blogs, online guides?
It will probably be more work than it's worth like you said, but anything i learn extra will be my profit.
cheers
I learned by trial & error and with the help of these forums. If you've had past experience, then I would recommend you just dive in and see how it goes. You can probably find answers to any basic VBA questions you have with Google. If you get stuck, come back here and me or somebody else will give you a hand.
To give you some basic direction, you'll probably want a vba macro that fires a form and dumps the data back to the models parameters. You can tie the macro directly to a ribbon button for your user to click.
Here's an example of a form I built in VBA for one of my applications:
This is the code tied to the "GO" button. It dumps all of the parameters that have been filled in by the user into the assembly file that called it. Yours doesn't need to be this complex, mine has a bit of error checking and a unit conversion built in.
Private Sub CommandButton1_Click() Dim iLogicAuto As Object Dim curDoc As Document Dim box As Boolean Dim TA As Double Dim TB As Double Dim TC As Double Dim TD As Double Dim TE As Double Dim TF As Double Dim TG As Double Dim TH As Double Dim TI As Double Dim TJ As Double Dim TK As String Dim BA As Double Dim BB As Double Dim BC As Double Dim BD As Double Dim BE As Double Dim BF As Double Dim BG As Double Dim BH As Double Dim BI As Double Dim BJ As Double Dim BK As String Dim conversion As Single On Error GoTo noValue: TA = boxTA.value If TA > 100 Then conversion = 25.4 Else conversion = 1 End If If topStud = True Then topThd = True TB = boxTB.value / conversion TC = boxTC.value / conversion TD = boxTD.value / conversion TE = boxTE.value / conversion TF = boxTF.value / conversion TG = boxTG.value / conversion TH = boxTH.value / conversion TI = boxTI.value / conversion TJ = boxTJ.value / conversion If topThd = False Then TK = boxTK.value / conversion Else TK = boxTK.value End If If botEqTop = True Then BA = TA BB = TB BC = TC BD = TD BE = TE BF = TF BG = TG BH = TH BI = TI BJ = TJ BK = TK botThd = topThd botStud = topStud Else BA = boxBA.value / conversion BB = boxBB.value / conversion BC = boxBC.value / conversion BD = boxBD.value / conversion BE = boxBE.value / conversion BF = boxBF.value / conversion BG = boxBG.value / conversion BH = boxBH.value / conversion BI = boxBI.value / conversion BJ = boxBJ.value / conversion If botThd = False Then BK = boxBK.value / conversion Else BK = boxBK.value End If If botStud = True Then botThd = True End If On Error GoTo functionNotFound: Set iLogicAuto = GetiLogicAddin(ThisApplication) If (iLogicAuto Is Nothing) Then box = MsgBox("GetiLogicAddin failed!", vbCritical, "Critical Error!") Exit Sub End If Set curDoc = ThisApplication.ActiveDocument On Error GoTo paramFail: iLogicAuto.paramvalue(curDoc, "topPlateWidth") = TA iLogicAuto.paramvalue(curDoc, "topPlateLength") = TB iLogicAuto.paramvalue(curDoc, "holeHorzOff") = TC iLogicAuto.paramvalue(curDoc, "holeVertOff") = TD iLogicAuto.paramvalue(curDoc, "squareHoleLength") = TE iLogicAuto.paramvalue(curDoc, "squareHoleWidth") = TF iLogicAuto.paramvalue(curDoc, "topSquareHolePatWidth") = TG iLogicAuto.paramvalue(curDoc, "topSquareHolePatHorzOff") = TH iLogicAuto.paramvalue(curDoc, "topSquareHolePatLength") = TI iLogicAuto.paramvalue(curDoc, "topSquareHolePatVertOff") = TJ If topThd = False Then iLogicAuto.paramvalue(curDoc, "topSquareHolePatHoleDia") = TK iLogicAuto.paramvalue(curDoc, "topTap") = False Else iLogicAuto.paramvalue(curDoc, "topTap") = True iLogicAuto.paramvalue(curDoc, "topThd") = TK End If If topStud = True Then iLogicAuto.paramvalue(curDoc, "topStud") = True Else iLogicAuto.paramvalue(curDoc, "topStud") = False End If iLogicAuto.paramvalue(curDoc, "botPlateWidth") = BA iLogicAuto.paramvalue(curDoc, "botPlateLength") = BB iLogicAuto.paramvalue(curDoc, "botHoleOffX") = BC iLogicAuto.paramvalue(curDoc, "botHoleOffZ") = BD iLogicAuto.paramvalue(curDoc, "botSquareHoleLength") = BE iLogicAuto.paramvalue(curDoc, "botSquareHoleWidth") = BF iLogicAuto.paramvalue(curDoc, "botSquareHolePatWidth") = BG iLogicAuto.paramvalue(curDoc, "botSquareHolePatHorzOff") = BH iLogicAuto.paramvalue(curDoc, "botSquareHolePatLength") = BI iLogicAuto.paramvalue(curDoc, "botSquareHolePatVertOff") = BJ If botThd = False Then iLogicAuto.paramvalue(curDoc, "botSquareHolePatHoleDia") = BK iLogicAuto.paramvalue(curDoc, "botTap") = False Else iLogicAuto.paramvalue(curDoc, "botTap") = True iLogicAuto.paramvalue(curDoc, "botThd") = BK End If If botStud = True Then iLogicAuto.paramvalue(curDoc, "botStud") = True Else iLogicAuto.paramvalue(curDoc, "botStud") = False End If If botEqTop = True Then iLogicAuto.paramvalue(curDoc, "flangesMatch") = False Else iLogicAuto.paramvalue(curDoc, "flangesMatch") = True End If On Error GoTo formFail: flangesSholeSpat.Hide Exit Sub noValue: box = MsgBox("Please make sure the form is completely and correctly filled out. Non numerical values are only OK in the hole diameter box. Don't use zero, fractions (except for thread designations), or expressions(formulae). No blank boxes!", vbOKOnly, "Missing Parameters") Exit Sub functionNotFound: box = MsgBox("GetiLogicAddin function not found! Something is probably wrong with your default.ivb file or the file path. Import your application settings from the .xml file in the templates folder.", vbCritical, "Function Not Found") Exit Sub paramFail: box = MsgBox("Parameter failed to set!", vbCritical, "Parameter Failure!") Exit Sub formFail: box = MsgBox("Form based failure!", vbCritical, "Form Failure!") Exit Sub End Sub
This is the "iLogicAuto" function that you'll need in order to access Inventor's parameters using the iLogicAuto.ParamValue() method I used above:
Public Function GetiLogicAddin(oApplication As Inventor.Application) As Object Dim addIns As ApplicationAddIns Set addIns = oApplication.ApplicationAddIns Dim addIn As ApplicationAddIn Dim customAddIn As ApplicationAddIn For Each addIn In addIns If (addIn.ClassIdString = "{3BDD8D79-2179-4B11-8A5A-257B1C0263AC}") Then Set customAddIn = addIn Exit For End If Next If customAddIn Is Nothing Then Dim box box = MsgBox("Add In not found!", vbCritical, "Critical Error!") End If addIn.Activate Set GetiLogicAddin = addIn.Automation End Function
This is the macro that summons the form (mine is meant to call one of several forms depending upon parameters input in an iLogic form):
Public Sub flanges(feed As String, pat As String) Dim box As Boolean If feed = "" Or pat = "" Then box = MsgBox("Problem passing variables to API", vbCritical, "Critical Error!") If feed = "Round" Then If pat = "UnDrilled" Then flangesRhole.Show ElseIf pat = "Round" Then flangesRholeRpat.Show ElseIf pat = "Square" Then flangesRholeSpat.Show End If ElseIf feed = "Square" Then If pat = "UnDrilled" Then flangesShole.Show ElseIf pat = "Round" Then flangesSholeRpat.Show ElseIf pat = "Square" Then flangesSholeSpat.Show End If End If End Sub
This isn't the best way, it certainly isn't the only way, and it's probably not the way I would do it now, but it is the way I did it a couple of years ago and it does work. So, hopefully this will be of help to you.
ok. i was able to do it with the help of the code you've provided. it was alot like walking in a dark room but got what i wanted nontheless
thx again.