几何尺寸与公差论坛

 找回密码
 注册
查看: 829|回复: 0

【转帖】propertymanager page problem

[复制链接]
发表于 2009-4-12 22:08:51 | 显示全部楼层 |阅读模式
propertymanager page problem
hello,
i'm working on a macro that gathers information on loops and i need to be able to select several edges with a propertymanager interface. i've got to a certain point where it works, but i can't get the 3,4 selection boxes to allow a selection, and if a selection is made in either 1,2,4,6 - it applies the selection to the other empty boxes. any ideas?
'this class defines the propertymanagerpage and its controls.
option explicit
'the propertymanagerpage
private m_page as sldworks.propertymanagerpage2
'the three groups that will contain the controls
'group1 (settings), group2 (ends), group3 (features)
private m_group1 as sldworks.propertymanagerpagegroup
private m_group2 as sldworks.propertymanagerpagegroup
private m_group3 as sldworks.propertymanagerpagegroup
'the controls on the page
private m_selection1 as sldworks.propertymanagerpageselectionbox
private m_selection2 as sldworks.propertymanagerpageselectionbox
private m_selection3 as sldworks.propertymanagerpageselectionbox
private m_selection4 as sldworks.propertymanagerpageselectionbox
private m_selection5 as sldworks.propertymanagerpageselectionbox
private m_selection6 as sldworks.propertymanagerpageselectionbox
private m_number as sldworks.propertymanagerpagenumberbox
private m_clearselection as sldworks.propertymanagerpagecheckbox
private m_button as sldworks.propertymanagerpagebutton
private m_label1 as sldworks.propertymanagerpagelabel
private m_label2 as sldworks.propertymanagerpagelabel
private m_label3 as sldworks.propertymanagerpagelabel
private m_label4 as sldworks.propertymanagerpagelabel
'whether the second group is active
private m_bgroup3 as boolean
'the id's for all of the controls
const id_group1 as long = 1
const id_group2 as long = 2
const id_group3 as long = 3
const id_selection1 as long = 4
const id_selection2 as long = 5
const id_selection3 as long = 6
const id_selection4 as long = 7
const id_selection5 as long = 8
const id_selection6 as long = 9
const id_number as long = 10
const id_button as long = 11
const id_label1 as long = 12
const id_label2 as long = 13
const id_label3 as long = 14
const id_label4 as long = 15
'required objects
dim clickedcancel as boolean
'create the page and place all of the controls on it.
private sub layout()
dim swapp as sldworks.sldworks
'objects needed to create the propertymanagerpage
dim pagehdlr as new propmgrhdlr
dim swpage as sldworks.propertymanagerpage2
dim swcontrol as sldworks.propertymanagerpagecontrol
dim title as string
dim message as string
dim caption as string
dim tip as string
dim buttontypes as long
dim id as long
dim options as long
dim filterarray(1) as long
dim errors as long
dim controltype as integer
dim alignment as integer
dim bret as boolean
'access solidworks
set swapp = getobject(, "sldworks.application")
'initialize the page handler
'pass it a reference to this propertymanagerpage
pagehdlr.init me
'set some variables for the page
title = "specific geometry selection"
buttontypes = swpropertymanager_okaybutton + swpropertymanager_cancelbutton
'create the propertymanagerpage
set m_page = swapp.createpropertymanagerpage(title, buttontypes, pagehdlr, errors)
'make sure that it was created properly
if errors = swpropertymanagerpage_okay then
'initial set up of the dialog.
message = "please select the id and od curves for the part in order to generate the cl paths."
m_page.setmessage message, swimportantmessagebox
'begin adding the required controls to the dialog.
'group box ----------------
id = id_group1
caption = "output settings"
options = swgroupboxoptions_visible + swgroupboxoptions_expanded
set m_group1 = m_page.addgroupbox(id, caption, options)
if not m_group1 is nothing then
'place these controls in the first group
'control label ------------------
id = id_label1
controltype = swcontroltype_label
caption = "tesselation chord length"
alignment = swcontrolalign_indent
options = swcontroloptions_visible + swcontroloptions_enabled
tip = "tesselation chord length"
set swcontrol = m_group1.addcontrol(id, controltype, caption, alignment, options, tip)
if not swcontrol is nothing then
set m_label1 = swcontrol
end if
'control number box ----------------
id = id_number
controltype = swcontroltype_numberbox
caption = "tess chord length"
alignment = swcontrolalign_indent
options = swcontroloptions_visible + swcontroloptions_enabled
tip = "tess chord length"
set swcontrol = m_group1.addcontrol(id, controltype, caption, alignment, options, tip)
if not swcontrol is nothing then
set m_number = swcontrol
m_number.setrange swnumberbox_length, -1000#, 1000#, 0.0001, true
m_number.value = 0.001
end if
end if
'group box ----------------
id = id_group2
caption = "end selection"
options = swgroupboxoptions_visible + swgroupboxoptions_expanded
set m_group2 = m_page.addgroupbox(id, caption, options)
if not m_group2 is nothing then
'place these controls in the second group
'control label ------------------
id = id_label2
controltype = swcontroltype_label
caption = "end 1"
alignment = swcontrolalign_indent
options = swcontroloptions_visible + swcontroloptions_enabled
tip = "label"
set swcontrol = m_group2.addcontrol(id, controltype, caption, alignment, options, tip)
if not swcontrol is nothing then
set m_label2 = swcontrol
end if
'control selection box ----------------
id = id_selection1
controltype = swcontroltype_selectionbox
caption = "end 1 id"
alignment = swcontrolalign_indent
options = swcontroloptions_visible + swcontroloptions_enabled
tip = "select id"
set swcontrol = m_group2.addcontrol(id, controltype, caption, alignment, options, tip)
if not swcontrol is nothing then
set m_selection1 = swcontrol
filterarray(0) = swseledges
filterarray(1) = swselrefcurves
'm_selection1.setselectionfilters (filterarray)
m_selection1.singleentityonly = true
m_selection1.mark = 1
end if
'control selection box ----------------
id = id_selection2
controltype = swcontroltype_selectionbox
caption = "end 1 od"
alignment = swcontrolalign_indent
options = swcontroloptions_visible + swcontroloptions_enabled + swcontroloptions_smallgapabove
tip = "select od"
set swcontrol = m_group2.addcontrol(id, controltype, caption, alignment, options, tip)
if not swcontrol is nothing then
set m_selection2 = swcontrol
filterarray(0) = swseledges
filterarray(1) = swselrefcurves
m_selection2.setselectionfilters (filterarray)
m_selection2.singleentityonly = true
m_selection2.mark = 2
end if
'control label ------------------
id = id_label3
controltype = swcontroltype_label
caption = "end 2"
alignment = swcontrolalign_indent
options = swcontroloptions_visible + swcontroloptions_enabled
tip = "label"
set swcontrol = m_group2.addcontrol(id, controltype, caption, alignment, options, tip)
if not swcontrol is nothing then
set m_label3 = swcontrol
end if
'control selection box ----------------
id = id_selection3
controltype = swcontroltype_selectionbox
caption = "end 2 id"
alignment = swcontrolalign_indent
options = swcontroloptions_visible + swcontroloptions_enabled
tip = "select faces and vertices"
set swcontrol = m_group2.addcontrol(id, controltype, caption, alignment, options, tip)
if not swcontrol is nothing then
set m_selection3 = swcontrol
filterarray(0) = swseledges
filterarray(1) = swselrefcurves
m_selection3.setselectionfilters (filterarray)
m_selection3.singleentityonly = true
m_selection3.mark = 4
end if
'control selection box ----------------
id = id_selection4
controltype = swcontroltype_selectionbox
caption = "end 2 od"
alignment = swcontrolalign_indent
options = swcontroloptions_visible + swcontroloptions_enabled + swcontroloptions_smallgapabove
tip = "select faces and vertices"
set swcontrol = m_group2.addcontrol(id, controltype, caption, alignment, options, tip)
if not swcontrol is nothing then
set m_selection4 = swcontrol
filterarray(0) = swseledges
filterarray(1) = swselrefcurves
m_selection4.setselectionfilters (filterarray)
m_selection4.singleentityonly = true
m_selection4.mark = 8
end if
end if
'group box ----------------
id = id_group3
caption = "feature selection"
options = swgroupboxoptions_visible + swgroupboxoptions_checkbox '+ swgroupboxoptions_expanded + swgroupboxoptions_checked
m_bgroup3 = false 'mark that the second group is disabled.
set m_group3 = m_page.addgroupbox(id, caption, options)
if not m_group3 is nothing then
'place these controls in the second group
'control label ------------------
id = id_label4
controltype = swcontroltype_label
caption = "feature selection"
alignment = swcontrolalign_indent
options = swcontroloptions_visible + swcontroloptions_enabled
tip = "label"
set swcontrol = m_group3.addcontrol(id, controltype, caption, alignment, options, tip)
if not swcontrol is nothing then
set m_label4 = swcontrol
end if
'control selection box ----------------
id = id_selection5
controltype = swcontroltype_selectionbox
caption = "sample selection box"
alignment = swcontrolalign_indent
options = swcontroloptions_visible + swcontroloptions_enabled
tip = "select faces and vertices"
set swcontrol = m_group3.addcontrol(id, controltype, caption, alignment, options, tip)
if not swcontrol is nothing then
set m_selection5 = swcontrol
filterarray(0) = swseledges
filterarray(1) = swselrefcurves
m_selection5.setselectionfilters (filterarray)
m_selection5.singleentityonly = true
'm_selection5.mark = 5
end if
'control selection box ----------------
id = id_selection6
controltype = swcontroltype_selectionbox
caption = "sample selection box"
alignment = swcontrolalign_indent
options = swcontroloptions_visible + swcontroloptions_enabled + swcontroloptions_smallgapabove
tip = "select faces and vertices"
set swcontrol = m_group3.addcontrol(id, controltype, caption, alignment, options, tip)
if not swcontrol is nothing then
set m_selection6 = swcontrol
filterarray(0) = swseledges
filterarray(1) = swselrefcurves
m_selection6.setselectionfilters (filterarray)
m_selection6.singleentityonly = true
'm_selection6.mark = 6
end if
end if
else
swapp.sendmsgtouser2 "there was an error creating the property manager page", swmbinformation, swmbok
end if
end sub
'display the property manager page
public sub show()
dim nretval as long
nretval = m_page.show
end sub
'generate the propertymanagerpage and it's controls
private sub class_initialize()
layout
end sub
private sub class_terminate()
'
end sub
your problem is you have not set the id to id_selection1 for the first box, so add that line. secondly you need to set the filter for selection and you have commented this out for selection 1 also. uncomment out the set filter line and the rest works fine.
hey luke, thanks for that. i was trying to debug it within the sw vba and for some reason it was not working properly. running it from solidworks made everything work fine.
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-23 13:56 , Processed in 0.039424 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表