dlanorh Posted July 19, 2019 Posted July 19, 2019 Solved, I hope, in the attached. Going to be away from my desk for the rest of the day. Any further problems I will try to sort this evening. bpv2.lsp Quote
tmelancon Posted July 19, 2019 Author Posted July 19, 2019 That did it! You enjoy your day! In the meantime I will do some research and mess around with the current code to try and see if I can figure out how to add additional attributes. Quote
dlanorh Posted July 20, 2019 Posted July 20, 2019 You can transfer all the attributes between the blocks by "translating" the tagstings of the 2 attributes that don't match between the two blocks. If you need help, let me know. Quote
BIGAL Posted July 21, 2019 Posted July 21, 2019 (edited) Hi dlanorh you can make this task a more universal program by looking at the block attribute order rather than tag names, say block has 8 attributes use a list of ones required (1 3 6) then get the values save in a list attlst, the same in the new block ( 1 4 7) which may not have matching positions or matching tag names. When you do the (foreach att (vlax-invoke (vlax-ename->vla-object blk ) 'getattributes) the 1st pass is just that attribute 1 next 2 and so on. Just do a check in list (1 4 7) and update if true (vla-put-textstring att (nth x attlst)) in this example x=0 1 2 Edited July 21, 2019 by BIGAL Quote
tmelancon Posted July 22, 2019 Author Posted July 22, 2019 Thanks BIGAL for chiming in. I have been messing around with the code trying to adapt it for multiple attributes but am having no luck. If you do not mind editing the code with your suggestions ONLY if you have spare time to even give this your valuable attention, I would greatly appreciate it. If not, I completely understand and do appreciate your already contributed valuable input. God bless. Quote
dlanorh Posted July 22, 2019 Posted July 22, 2019 Have a look at the attached. This is the previous lisp adapted to transfer ALL the attribute values between the two block. bpv3.lsp Quote
tmelancon Posted July 22, 2019 Author Posted July 22, 2019 Oh nice what a remarkable code! I cannot thank you enough! WOW! When I get in an old drawing with an old titleblock that somehow has the titeblock named "TBLOCK-NEW" it says: Duplicate definition of block TBLOCK-NEW ignored and doesn't appear to insert the new titleblock. Any idea? Other than that this is fantastic! THANK YOU SO MUCH ! Quote
tmelancon Posted July 22, 2019 Author Posted July 22, 2019 (edited) I found a quick fix, not sure if it was the right fix. I commented out the vlax-invoke and inserted vla-purgeall above the setq ss nil. (vla-PurgeAll c_doc) (setq ss nil) ;(vlax-invoke c_doc 'purgeall) Edited July 22, 2019 by tmelancon change Quote
tmelancon Posted July 22, 2019 Author Posted July 22, 2019 Ok I thought it was a quick fix. Apparently not. Quote
tmelancon Posted July 22, 2019 Author Posted July 22, 2019 If I run the rename command and rename the old titeblock back to BLOCK, then run the command it works just fine. So apparently if it comes across an old block that for some unknown reason was named TBLOCK-NEW but was never replaced, it just ignores it. Quote
dlanorh Posted July 22, 2019 Posted July 22, 2019 20 minutes ago, tmelancon said: I found a quick fix, not sure if it was the right fix. I commented out the vlax-invoke and inserted vla-purgeall above the setq ss nil. (vla-PurgeAll c_doc) (setq ss nil) ;(vlax-invoke c_doc 'purgeall) They are the same thing. You can also use (vlax-invoke-method c_doc 'purgeall) If the drawing already contains a block called "TBLOCK-NEW" but it is not the correct one you'll have change the first ssget to read (mapcar 'setvar sv_lst '(0 0)) (setq ss (ssget "_X" '((0 . "INSERT") (2 . "TBLOCK,TBLOCK-NEW")))) The mapcar statement is just for reference to find the line. This will find a block(s) called either "TBLOCK or TBLOCK-NEW" Quote
tmelancon Posted July 22, 2019 Author Posted July 22, 2019 Ah I see. Just updated code and ran it and got this error. It did in fact delete the old one and insert new one though, just did not populate it with anything. Oops an Error : ActiveX Server returned an error: Parameter not optional occurred Quote
dlanorh Posted July 22, 2019 Posted July 22, 2019 I have no idea what is causing that. What it means is an activeX call needs to have a parameter which is not present, so something just changed possibly. Quote
dlanorh Posted July 22, 2019 Posted July 22, 2019 OK, I've tried my modification (2 . "TBLOCK,TBLOCK-NEW") after renaming the block in the tester drawing, and everything works OK. Quote
tmelancon Posted July 22, 2019 Author Posted July 22, 2019 (edited) I have attached the current Titleblock in question but just changed every attribute text to test1, test2, test3, etc.. for testing purposes. Getting error Oops an Error : ActiveX Server returned an error: Parameter not optional occurred. Please let me know your thoughts. Also changed the code just for this instance: ot_lst (list "FECILITY");THESE ARE THE OLD TAG NAMES TO BE UPDATED nt_lst (list "PLATFORM");THESE ARE THE CORRESPONDING NEW TAG NAMES FACILITY was misspelled in the old titleblock so I type it as it is, and the new corresponding tag in the new titleblock that the information should show up in is PLATFORM. Which I have updated my code to reflect. Please advise. TEST-LATEST.dwg Edited July 22, 2019 by tmelancon edit Quote
dlanorh Posted July 22, 2019 Posted July 22, 2019 The old block in this drawing has two attribute tags with same name "DATE", this is always going to cause problems. Neither of these attribute tags is in the new block and they are not in the tag translation strings, hence the error. If a tag in the old block has a different name to a corresponding tag in the new block it needs to be explicitly translated in the two lists. You can leave old items in the lists and just add new items to the end. The only limiting factor is unique tag names in the "OLD" list as this controls the name translation, the lists can be as long as you like provided each entry has a corresponding correct entry in the new list. With regards to the two tags with the same name, there are two possible solutions, omit updating the tags or try to find a solution to identify which corresponds to what in the new titleblock. I would plump for the first option. I've already implimented it in the attached revised lisp. I have updated Old/New list. Notice that the "INSPECTED" appears in the new list twice. This is allowed as the old list controls the translation. Another point to consider is the fullstop in one of the tag names. This threw me as it wasn't immediately obvious why it wouldn't translate. If you need to change block tag names you should use the "BATTMAN" command (Block ATTribute MANager). bpv3.lsp Quote
tmelancon Posted July 23, 2019 Author Posted July 23, 2019 (edited) This is why in the example code and block I just recently sent, I removed all but the “FECILITY” tag in the code which like I said was the old misspelled tag in the old titleblock just to use for our test, and specified “PLATFORM” as the new tag. I removed DATE and stuff for this reason. This was just to test on a single attribute as to why I was getting the error. Edited July 23, 2019 by tmelancon Edit Quote
BIGAL Posted July 23, 2019 Posted July 23, 2019 (edited) Hi guys if block 1 has the same number and ORDER as block 2 then using order is very quick else like I say if its something being done all the time need to look at order. It looks like 8 attributes so I know a way to do block1 pick block2 new order of attributes. I think I have done this before lots of stuff I have not saved. This is what I am thinking of tagnmes not tagx then enter order if 0 don't do. It will grow or shrink depending on number of atts. Edited July 23, 2019 by BIGAL Quote
dlanorh Posted July 23, 2019 Posted July 23, 2019 6 hours ago, tmelancon said: This is why in the example code and block I just recently sent, I removed all but the “FECILITY” tag in the code which like I said was the old misspelled tag in the old titleblock just to use for our test, and specified “PLATFORM” as the new tag. I removed DATE and stuff for this reason. This was just to test on a single attribute as to why I was getting the error. Sorry didn't realise that that was your intention. It would seem the error was being generated when no equivalent value for a given tag name was found in the list. By checking if such a value is available we can now avoid this. Attached is a further tweaked lisp. This now prints a list of attributes (by tag name) where it couldn't fill a value. bpv3.lsp Quote
dlanorh Posted July 23, 2019 Posted July 23, 2019 @BIGAL Currently both blocks are not present in the drawing at the same time. All the info is collected from the old one, it is deleted, the drawing purged, and then the new block is inserted and updated. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.