gigi.iacu
Guest
ilogic macro numeri progressivi: ho creato una regola su ilogic che al click del mouse mi posiziona un numero progressivo. però, a random, esce dalla macro. ne vorrei capire il perchè.
allego programma. si basa su un foglio.idw.
ho creato una nota sugli editor dei testi chiamata premontaggio ( ostyle = odoc.stylesmanager.textstyles.item("premontaggio"))
ho creato una variabile personalizzata chiamata premontaggio che va aprendere il valore attraverso un modulo. sulla macro sotto trovate anche un input box con apice iniziale.
sub main()
'parameter.updateafterchange = true
dim n_premontaggio as integer
dim ointeraction as interactionevents
ointeraction = thisapplication.commandmanager.createinteractionevents
dim omouse as mouseevents
omouse = ointeraction.mouseevents
addhandler omouse.onmouseclick, addressof omouse_onmousedown
ointeraction.start
'parameter("premontaggio") = inputbox("inserire numero premontaggio", "premontaggio", parameter("premontaggio"))
end sub
sub omouse_onmousedown(button as mousebuttonenum, shiftkeys as shiftstateenum, modelposition as point, viewposition as point2d, view as inventor.view)
parameter.updateafterchange = true
dim odrawdoc as drawingdocument
odrawdoc = thisapplication.activedocument
' set a reference to the active sheet.
dim oactivesheet as sheet
oactivesheet = odrawdoc.activesheet
' set a reference to the generalnotes object
dim ogeneralnotes as generalnotes
ogeneralnotes = oactivesheet.drawingnotes.generalnotes
dim otg as transientgeometry
otg = thisapplication.transientgeometry
' create text with simple string as input. since this doesn't use
' any text overrides, it will default to the active text style.
dim stext as string
'messagebox.show(1,1)
dim ogeneralnote as generalnote
' create a set of notes that are numbered and aligned along the left.
dim dycoord as double
dim dxcoord as double
dycoord = modelposition.y
dxcoord = modelposition.x
dim ostyle as textstyle
dim odoc as drawingdocument
odoc = thisapplication.activedocument
ostyle = odoc.stylesmanager.textstyles.item("premontaggio")
'messagebox.show(2,2)
ogeneralnote = ogeneralnotes.addfitted(otg.createpoint2d(dxcoord, dycoord), parameter("premontaggio"), ostyle)
'messagebox.show(3,3)
parameter("premontaggio") = parameter("premontaggio") + 1
'messagebox.show(4,4)
end sub
allego programma. si basa su un foglio.idw.
ho creato una nota sugli editor dei testi chiamata premontaggio ( ostyle = odoc.stylesmanager.textstyles.item("premontaggio"))
ho creato una variabile personalizzata chiamata premontaggio che va aprendere il valore attraverso un modulo. sulla macro sotto trovate anche un input box con apice iniziale.
sub main()
'parameter.updateafterchange = true
dim n_premontaggio as integer
dim ointeraction as interactionevents
ointeraction = thisapplication.commandmanager.createinteractionevents
dim omouse as mouseevents
omouse = ointeraction.mouseevents
addhandler omouse.onmouseclick, addressof omouse_onmousedown
ointeraction.start
'parameter("premontaggio") = inputbox("inserire numero premontaggio", "premontaggio", parameter("premontaggio"))
end sub
sub omouse_onmousedown(button as mousebuttonenum, shiftkeys as shiftstateenum, modelposition as point, viewposition as point2d, view as inventor.view)
parameter.updateafterchange = true
dim odrawdoc as drawingdocument
odrawdoc = thisapplication.activedocument
' set a reference to the active sheet.
dim oactivesheet as sheet
oactivesheet = odrawdoc.activesheet
' set a reference to the generalnotes object
dim ogeneralnotes as generalnotes
ogeneralnotes = oactivesheet.drawingnotes.generalnotes
dim otg as transientgeometry
otg = thisapplication.transientgeometry
' create text with simple string as input. since this doesn't use
' any text overrides, it will default to the active text style.
dim stext as string
'messagebox.show(1,1)
dim ogeneralnote as generalnote
' create a set of notes that are numbered and aligned along the left.
dim dycoord as double
dim dxcoord as double
dycoord = modelposition.y
dxcoord = modelposition.x
dim ostyle as textstyle
dim odoc as drawingdocument
odoc = thisapplication.activedocument
ostyle = odoc.stylesmanager.textstyles.item("premontaggio")
'messagebox.show(2,2)
ogeneralnote = ogeneralnotes.addfitted(otg.createpoint2d(dxcoord, dycoord), parameter("premontaggio"), ostyle)
'messagebox.show(3,3)
parameter("premontaggio") = parameter("premontaggio") + 1
'messagebox.show(4,4)
end sub
Last edited: