![]() |
【转帖】how can i insert the serial number note
how can i insert the serial number note?
i would like to create the serial number note, that like the new note insert to the drawing. the first note i can set the start number,next note is serial number . how can i to wite the marco for serial number note. the serial number likes the following picture. sha , check this attached macro if it solves your purpose. i have recorded it and then edited the note position. deepak gupta sw2007 sp5.0 sw2009 sp2.1 deepak, thanks for your macro,but i'm sorry,the macro is not i want. my english is poor,so the purpose is not clearly understood. my purpose is use the serial number for mark the dimensions. the max serial number depends on the count of dimensions. you can set the start number. to this day,i can use the select point to set the insert position. but it is not best way,i want a more convenient way. my idea : i can insert the note and move it with the mouse,then click to set the position,then create new note with the next serial number ......,then press esc key to exit the process, it likes the new note be inserted to the drawing in sw application. so i must understand that sw note tool is how to insert the notes. can you solves my purpose? if you have the other better way , please tell me. thank you ! edited: 03/23/2009 at 10:14 am by sha zhehua something like this macro? dim swapp as sldworks.sldworks dim swdoc as sldworks.modeldoc2 dim swdwg as sldworks.drawingdoc dim swview as sldworks.view dim swdispdim as sldworks.displaydimension dim swdim as sldworks.dimension dim scursuffix as string dim nopenparpos as long dim ncloseparpos as long dim vdimval as variant dim dinchval as double dim sinchstring as string dim snewsuffix as string dim killflag as integer dim smsg as string dim srefpfx as string dim nrefnum as long dim nstartnum as long const defsym as string = "c#-" sub adddimrefnums() set swapp = application.sldworks set swdoc = swapp.activedoc if swdoc.gettype <> swdocdrawing then msgbox "this macro only works for drawing files." exit sub end if smsg = "this macro will add a symbol containing a dimension reference number " & _ vbcrlf & "to all dimensions in this drawing." & vbcrlf & vbcrlf & _ "to add or update dimension reference symbols, choose ""yes""" & vbcrlf & _ "to remove reference symbols, choose ""no""" & _ vbcrlf & "to quit, choose ""cancel""" killflag = msgbox(smsg, vbyesnocancel, "dimension reference symbols") if killflag = vbcancel then exit sub end if if killflag = vbyes then srefpfx = inputbox("please enter the desired symbol code." & vbcrlf & _ "for example, ""c#-"" for circles, ""s#-"" for squares." & vbcrlf & _ "note that symbol codes are case sensitive.", "symbol type", defsym) nstartnum = clng(inputbox("enter starting number", "start", 1)) else srefpfx = "" end if set swdwg = swdoc nrefnum = nstartnum set swview = swdwg.getfirstview while not (swview is nothing) set swdispdim = swview.getfirstdisplaydimension5 while not swdispdim is nothing set swdim = swdispdim.getdimension sinchstring = srefpfx & nrefnum nrefnum = nrefnum + 1 scursuffix = swdispdim.gettext(swdimensiontextsuffix) nopenparpos = instr(1, scursuffix, "<", vbtextcompare) ncloseparpos = instr(1, scursuffix, ">", vbtextcompare) if (killflag = vbno) and (nopenparpos > 0) and (ncloseparpos > 0) then snewsuffix = left(scursuffix, nopenparpos - 1) snewsuffix = snewsuffix & right(scursuffix, len(scursuffix) - ncloseparpos) elseif (nopenparpos > 0) and (ncloseparpos > 0) then snewsuffix = left(scursuffix, nopenparpos) snewsuffix = snewsuffix & sinchstring snewsuffix = snewsuffix & right(scursuffix, len(scursuffix) - (ncloseparpos - 1)) else if killflag <> vbno then snewsuffix = trim(scursuffix) & " <" & sinchstring & ">" else snewsuffix = scursuffix end if end if swdispdim.settext swdimensiontextsuffix, snewsuffix set swdispdim = swdispdim.getnext5 wend set swview = swview.getnextview wend end sub i'll get you eh steve, if it's the last thing i dooooo! josh, thanks for your macro. i was glad to tested your macro, it is a good way of my purpose, but i also have some programs. 1. in position the nearly number is too far, it's difficult to find the next number. i don't know the order of the number's position. the order i hope is top-left-down-right. look at the attachment of order. 2. the number must be less than 100, if not ,the display is error. 3. the same number appeared. 4. if i want to insert number for a part of dimensions , how can i do? the comment has changed, please see it again. edited: 03/24/2009 at 03:31 am by sha zhehua click for full image answer try this one. run the macro and a form will pop up. you can choose from circle, triangle, or square symbols. the number in the text box is the next symbol number. every time you click on a dimension it will put the number from the box in as a symbol, then increment the number. if the "delete" box is checked, it will delete the symbol from each dimension you click. i'll get you eh steve, if it's the last thing i dooooo! josh, thanks for your good macro, it realized my purpose basically. but, the number must less than 100, that is the last problem , is't very important. i must add the symbol in symbols library file for the number, that is a troublesome thing, and the other sw users can not use the symbol before they get the symbol file. so i can't use the symbol for the number, i try to use the note for the number,that is my first idea. i will try to edit your macro for insert the note when select proint. just now i have new ideas. i will retain your idea, and add my idea in marco. you can choose the both of way to insert number , if the number is less than 100,then you can choose the symbol way ;if the number is more than 99 ,then you can choose the note way. i think that is the better way. your fast reply, thank you very much! edited: 03/25/2009 at 12:56 am by sha zhehua if you can use the native sw dim naming, all dims are currently numbered. you can just turn number description on in the options. matt lorono solidworks 2007 sp3.1 cad engineer/ecn analyst hi matthew, i don't know where is the number description about your said in the sw options, i think you said is "show dimension's names", it's right? but that can not realize to my purpose , there is some problem. 1. when i insert the dim for design model, usually i don't consider the order of the dim. 2. there is the same name of dim in the different sketch, without the reference dimensions,through you can use the number to rename each dim, that is a troublesome thing. 3. you can't set the position of the dim's name in display, adjust the position of each dim is a troublesome thing. thanks. edited: 03/26/2009 at 08:09 am by sha zhehua hi to this day, i have realized my mind with your help. i have sent the answer to josh . and the last macro interface is in the attachment , please have a look. thank you very much. click for full image |
所有的时间均为北京时间。 现在的时间是 05:56 PM. |