几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   SolidWorks二次开发 (http://www.dimcax.com/hust/forumdisplay.php?f=111)
-   -   【转帖】need vb code for dimension override value (http://www.dimcax.com/hust/showthread.php?t=4837)

yang686526 2009-04-12 09:53 PM

【转帖】need vb code for dimension override value
 
need vb code for dimension override value
i am in need of some code that gets a specific dimension and sets the override value of that dimension to any number i choose.
here is all i could find:
dim instance as idisplaydimension
dim override as boolean
dim value as double
dim value as boolean
value = instance.setoverride(override, value)
this is probably easier than i am making it out to be lol. i don't know what to put to get d1@sketch3 to be an override value of 50. thank you for any help!
-solidworks 2009 sp1
--dell precision m6300-
---intel core2 duo t9300------------------------
----nvidia quadro fx 3600m - 4gb ram----------
hi,
this works for me. have a drawing as the active document and edit the select statement to name a dimension in a view.
dim swapp as sldworks.sldworks
dim part as modeldoc2
dim selmgr as selectionmgr
dim dispdim as displaydimension
dim theval as double
sub main()
set swapp = application.sldworks
set part = swapp.activedoc
set selmgr = part.selectionmanager
boolstatus = part.extension.selectbyid2("rd1@drawing view1", "dimension", 0, 0, 0, false, 0, nothing, 0)
set dispdim = selmgr.getselectedobject6(1, 0)
theval = (50 * 25.4) / 1000 'in meters
dispdim.setoverride true, theval
end sub
scott
quick


所有的时间均为北京时间。 现在的时间是 03:42 PM.