adamsdr3 Posted October 6, 2015 Posted October 6, 2015 (edited) Let me start out by saying that I'm much more fluent in excel VBA than I am in autoCAD vba. I have around 200 drawings in sheet set. Half of the sheet numbers are just numbers and the other half are numbers with a D at the end. I want to add a dash before the D if the sheet number has one. Basically, I need to make this 1 1D 2 2D 3 3D look like this 1 1-D 2 2-D 3 3-D I wrote something that would do it in excel if it helps but I have no idea how to specify the sheet set or even the sheet number property for each drawing...Here's what I wrote in excel. It's simple and it works great. Public Sub demolition() For Each cell In Range("E6:E13") If Right(cell.Text, 1) = "D" Then cell.Value = Left(cell.Text, Len(cell.Text) - 1) End If Next cell End Sub Edited October 6, 2015 by adamsdr3 Quote
Lt Dan's legs Posted October 6, 2015 Posted October 6, 2015 Is it text or block attribute? Individual dwg's? all one but different viewports? I'm not sure this will help but... (setq lst '("1" "1D" "2" "3" "3D" "4")) (repeat (setq n (length lst)) (and (wcmatch (strcase (nth (setq n (1- n)) lst)) "*D") (setq lst (subst (vl-string-subst "-D" "D" (nth n lst)) (nth n lst) lst ) ) ) ) Quote
adamsdr3 Posted October 6, 2015 Author Posted October 6, 2015 It is neither text or a block attribute. They are all individual dwg's with different viewports. I basically just need to change the sheet number property within sheetset Quote
Lt Dan's legs Posted October 6, 2015 Posted October 6, 2015 the tab names? or drawing (dwg) names? Forgive my ignorance, I haven't had to deal with sheet sets in 8years Quote
adamsdr3 Posted October 6, 2015 Author Posted October 6, 2015 Each sheet set has subsets (what I think you're callings tabs). Within the subset are the sheets. Each sheet in sheet set has 2 properties; a sheet number and a sheet title. The code that I need to run effects the sheet number. Quote
Lt Dan's legs Posted October 6, 2015 Posted October 6, 2015 (edited) For just the active document. (vlax-for x (vla-get-Layouts (vla-get-activedocument (vlax-get-acad-object))) (and (setq n (strcase (vla-get-name x))) (eq (substr n (setq nl (strlen n)) 1) "D") (vla-put-name x (strcat (substr n 1 (1- nl)) "-D")) ) ) For multiple dwgs (vlax-for d (vla-get-documents (vlax-get-acad-object)) (vlax-for x (vla-get-Layouts d) (and (setq n (strcase (vla-get-name x))) (eq (substr n (setq nl (strlen n)) 1) "D") (vla-put-name x (strcat (substr n 1 (1- nl)) "-D")) ) ) ) Edited October 6, 2015 by Lt Dan's legs Cleaning things up Quote
adamsdr3 Posted October 6, 2015 Author Posted October 6, 2015 Thanks for your help. Before I run this on the test sheetset I made, how does it select the sheetset that it runs on? is it the set that is currently active? Quote
Lt Dan's legs Posted October 6, 2015 Posted October 6, 2015 check the gif out. I hope this is what you want (fingers crossed) Quote
adamsdr3 Posted October 6, 2015 Author Posted October 6, 2015 I'm honestly completely lost. I read up on how to load a LSP file. I pasted the text into notepad and saved the file with a .LSP extension. then I loaded it into autocad and typed the name into the prompt. here is the result. Sorry. Still new to Lisp http://imgur.com/QCeXiC2 Quote
Tharwat Posted October 6, 2015 Posted October 6, 2015 Dan, the Sheet set is different than layouts though Sheet set can not be modified or in other words AutoLISP have no access to Sheet sets at all. Quote
Lt Dan's legs Posted October 6, 2015 Posted October 6, 2015 I see. See comment #4. lol Thank you for your input, Tharwat. I would've been driving myself crazy over this Quote
adamsdr3 Posted October 6, 2015 Author Posted October 6, 2015 I found the code I need to change the sheet number property, now all I need is a way to loop through them all. In excel, I just defined the cells I need to loop through as a range. Does anyone know if there is a way to do something similar for the sheets in a subset in VBA? Quote
Tharwat Posted October 6, 2015 Posted October 6, 2015 (edited) I see. See comment #4. lol Sorry , I have read all OP's replies to get sure if they meant Layout in any other words but couldn't find any, so that's why I wanted to pay your attention to it. Edited October 7, 2015 by Tharwat 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.