Jump to content

Sebastiaan

Member
  • Posts

    379
  • Joined

  • Last visited

Reputation

126 Spectacular

1 Follower

Personal Information

  • Location
    Netherlands

Recent Profile Visitors

3,269 profile views
  1. It is good practice to always import dwg’ s into a new blank file Unless you know for sure you need to do it in the project file. A DWG import could change your user origin for instance if you have the recommended settings turned on.
  2. Ah yes. No problem to do the purge by hand. In this case the script will automate enough work. Thx!
  3. I was thinking of just doing a purge after running the script that should work to clean up the RM shouldn’t it?
  4. Thanks @MullinRJ, playing with SetHDef() And got it to work on the first test! with below code. Now to expand the script to finish the challenge thx! vs.SetHDef('_TransformGroup', 'Group') symid = vs.FInFolder( vs.GetObject( 'DXF_DWG' ) ) while vs.GetTypeN(symid)==16: symname = vs.GetName(symid) if symname[:20] == 'Lighting Device (3D)': #for i in range(4): symDef = vs.FInSymDef(vs.GetObject(symname)) #for i in range(4): symDefName = vs.GetSymName(symDef) #vs.AlrtDialog(symDefName) if symDefName[:15] == '_TransformGroup': #vs.AlrtDialog(symDefName) Symobjnew = vs.GetObject('Group') vs.AlrtDialog(Symobjnew) vs.AlrtDialog(symDef) vs.SetHDef(symDef, Symobjnew) #vs.SymbolToGroup(symDef,0) symDef = vs.NextObj(symDef) else: symDef = vs.NextObj(symDef) symid=vs.NextSymDef(symid)
  5. Also would you or anyonknow if there is a function to delete and replace a symbol definition directly in the recourse manager like we can do with right click on the symbol in the resource manager? Can this be done with scripting too? It would be an alternate and maybe even better approach to my end goal of this challenge. @MullinRJ @Pat Stanford?
  6. What you said about the stacking order does make sense, as after the first SymboltoGroup the next object seemed to become the next nested symbol that was in the symbol that I converted to group. I did try the list approach, I made a list of the nested symbols with the getname function, but it seemed to do nothing, as if this does not work when you are withinin a parent symbol? Am alertdialog would name the symbols but the convert to group did nothing. Could you give an example of how to get all handles of the symbol? Do you mean getting all 4 handles of all 4 symbols that I want to convert via a list? Or more handles per symbol? Edit: btw I had added the example file in the opening post 🙂 I did manage to make this part of my quest to work with the following workaround by nesting the convert loop in a another loop, that way I could break the sequence and run it again until all 4 symbols are converted symid = vs.FInFolder( vs.GetObject( 'DXF_DWG' ) ) while vs.GetTypeN(symid)==16: symname = vs.GetName(symid) if symname[:20] == 'Lighting Device (3D)': for i in range(4): symDef = vs.FInSymDef(vs.GetObject(symname)) for i in range(4): symDefName = vs.GetSymName(symDef) #vs.AlrtDialog(symDefName) if symDefName[:15] == '_TransformGroup': #vs.AlrtDialog(symDefName) vs.SymbolToGroup(symDef,0) symDef = vs.NextObj(symDef) else: symDef = vs.NextObj(symDef) symid=vs.NextSymDef(symid)
  7. I am trying to convert to group symbols nested in a 3d symbol. Each parent 3D symbol has 4 nested 3d Symbols that I want to convert to group, but each nested 3D symbol may also have nested symbols of their own. I am trying to convert to group the first set of 4 nested symbols whose names al start with '_TransformGroup'. I am using vs.FInSymDef to get to the first nested object. With the below code I can use the for loop to show each of the 4 symbol names in an alert dialog if I omit the vs.SymbolToGroup line. But as soon as I add the vs.SymbolToGroup line the code stops and does not go to the next object as expected. Could anyone point me in the right direction? symid = vs.FInFolder( vs.GetObject( 'DXF_DWG' ) ) while vs.GetTypeN(symid)==16: symname = vs.GetName(symid) if symname[:20] == 'Lighting Device (3D)': symDef = vs.FInSymDef(vs.GetObject(symname)) for i in range(4): symDefName = vs.GetSymName(symDef) #vs.AlrtDialog(symDefName) if symDefName[:15] == '_TransformGroup': vs.AlrtDialog(symDefName) vs.SymbolToGroup(symDef,0) symDef = vs.NextObj(symDef) else: symDef = vs.NextObj(symDef) symid=vs.NextSymDef(symid) Reduce nested symbols script.vwx
  8. There is a Coffee Break seminar on the VW university about exactly this subject. It might be worth it to watch that one. some tips may be unexpected like images used in a title block can increase file size.
  9. Hi Pat, Thank you. I must admit I was secretly hoping for you. But by not having the time you motivated me to do it myself ;-). I couldn't let it go and I now have it working for the second level with nested folders too! There are a couple of items in the import that could have been in a third folder but I am not going to bother with that. Very happy with the result and that I managed myself. See the code and example file below: symid = vs.FInFolder( vs.GetObject( 'DXF_DWG' ) ) fldrlist = [] symlist = [] while vs.GetTypeN(symid)==16: symname = vs.GetName(symid) symsub = vs.SubString(symname,'_',2) if symsub not in fldrlist: fldrlist.append(symsub) symlist.append(symname) symid=vs.NextSymDef(symid) cntsym = (len(fldrlist)) cntsym2 = (len(symlist)) sym=symid scndlist = [] for i in range(len(fldrlist)): fldr1 = fldrlist[i] for j in range(len(symlist)): symname = symlist[j] scndfldr = vs.SubString(symname,'_',3) chkfldr = vs.SubString(symname,'_',2) if scndfldr not in scndlist and chkfldr == fldr1 and symname.count('_') >= 3: scndlist.append(scndfldr) vs.NameObject(fldr1) vs.BeginFolderN(16) for k in range(len(scndlist)): fldr2 = scndlist[k] vs.NameObject(fldr2) vs.BeginFolderN(16) vs.EndFolder() vs.EndFolder() scndlist.clear() for i in range(len(symlist)): symname = symlist[i] if symname.count('_') >= 3: fname = vs.SubString(symname,'_',3) else: fname = vs.SubString(symname,'_',2) insrtfldr = vs.GetObject(fname) insrtsym = vs.GetObject(symname) vs.InsertSymbolInFolder(insrtfldr, insrtsym) Folder script.vwx
  10. update: I managed to get a script working for creating folder based on a substring of the symbol names. And placing the symbols in their corresponding folders. This does not create nested folders yet, but I may leave it at this an enough of a satisfactory result. Maybe I could get it to work to create multiple nested folders if I make a list with a sublist of substrings or something like that. symid = vs.FInFolder( vs.GetObject( 'DXF_DWG' ) ) fldrlist = [] symlist = [] while vs.GetTypeN(symid)==16: symname = vs.GetName(symid) symsub = vs.SubString(symname,'_',2) #vs.AlrtDialog(symsub) fldrlist.append(symsub) symlist.append(symname) symid=vs.NextSymDef(symid) cntsym = (len(fldrlist)) vs.AlrtDialog(cntsym) sym=symid if vs.GetTypeN(sym)!=16: vs.AlrtDialog('All symbols shown') i = 1 while i < len(fldrlist): fname = fldrlist[i] chkfldr = vs.GetObject(fname) if chkfldr == 0: #vs.AlrtDialog(fname, ' ', chkfldr) vs.NameObject(fname) vs.BeginFolder() vs.EndFolder() i = i + 1 i = 0 while i < len(symlist): symname = symlist[i] fname = vs.SubString(symname,'_',2) insrtfldr = vs.GetObject(fname) insrtsym = vs.GetObject(symname) #vs.AlrtDialog(insrtsym) vs.InsertSymbolInFolder(insrtfldr, insrtsym) i = i + 1 #vs.AlrtDialog(vs.SubString(Symname,'_',2))
  11. Maybe this topic should be moved to the Python forum because I have been trying some different code snippets in Python. I can create a folder in a folder or even two folders in one folder with the below code. It would only have to be made dynamic based on then delimited substrings of the symbols. vs.NameObject('Audio') vs.BeginFolderN(16) vs.NameObject('AudioSubfolder') vs.BeginFolderN(16) vs.EndFolder() vs.NameObject('AudioSubfolderSCND') vs.BeginFolderN(16) vs.EndFolder() vs.EndFolder() I can loop through a list of symbols in a folder and place a symbol in it's folder based on the last substring delimited by '_' However some how it only places one symbol in its folder I have to run the script again to get the next one in its folder? symid = vs.FInFolder( vs.GetObject( 'DXF_DWG' ) ) while vs.GetTypeN(symid)==16: symname=vs.GetName(symid) symdepth = symname.count('_') fname = vs.SubString(symname,'_',symdepth) insrtfldr = vs.GetObject(fname) insrtsym = vs.GetObject(symname) vs.InsertSymbolInFolder(insrtfldr, insrtsym) #vs.AlrtDialog(symdepth,fname) symid=vs.NextSymDef(symid) So making small steps, it has just been to long ago since I coded anything and these bit of code are copied from various topics. Would anyone be willing to give me a push?
  12. Ok different aproach. I used an Automator finder quick action to batch rename the DWG's with a prefix based on the nested folders that the DWG's are in. Before the name was Product abc.dwg and below is the result. This is an anonymised example file and folder structure. I can now import the DWG's as symbols into 1 file and this will at least sort the imported symbols in the recourse manager in the same order as the folder structure. With two example files this import wil look like this in the RM: Now would it be possible with a script to loop through the symbols in the RM and create folders and subfolders based on the prefixes delimited by the '_' in the symbol? The desired result would look like this: As far as I can see there won't be an issue with the 63 character limit looks like I am staying under that. The actual data set has 1000's of dwg's to convert so manual operation is not really an option. The sorted import list is already sort of workable, but if the above script would be possible I would be forever grateful.
  13. Hi, I have a set of many tiny DWG's spread across dozens of folders that I would want to import in place into VW files. When I use the import DWG/DXF command then I can import all DWG's into one folder or all DWG's into one file. But what I would really want is is to have a batch import where for each folder of DWG's the import is done into that folder either one VW file with all DWG's from that folder or if that's not possible for each folder containing DWG's the import is done into that folder with one VW file per DWG file. Even more I would want the DWG geometry to be imported as symbols into the VW files. Would something like this be possible or should I start thinking about apple script?
  14. Make sure that the field you want to number has a ✅ in the column ont the left of the window. also when you want to alter the setting of the field make sure that you click on the field name on the left and that it is highlited blue when you enter something in the field settings. these two are the most common user errors to check.
  15. Are these older drawings? In my files there is no “Channel Number” field. Just “channel” without the number.
×
×
  • Create New...