jamami Posted Tuesday at 05:49 PM Posted Tuesday at 05:49 PM I am updating a dynamic block using dummy parameters to achieve multiple visibility states, I have got it working at 2m and 3m by manually inputting data but I need to go to 40m and there are 9 visibility states for for each length. I can generate the data in Excel and ideally I want to cut paste this into the property lookup table but this is not possible. I can cut paste into a block property table but not a lookup table and adding 300+ lines manually in 3 separate tables is not practical. The attached image shows one table completed for 2 and 3m lengths. Can this data be scripted ? Quote
BIGAL Posted Tuesday at 11:42 PM Posted Tuesday at 11:42 PM I don;t think you need Excel. You can match a dcl to a dynamic block so you can enter values and then in turn update the block. It is something I have insert block and the dcl is displayed, its global code so works with any dynamic block. Need a dwg with your block and can test. Quote
jamami Posted Wednesday at 06:31 AM Author Posted Wednesday at 06:31 AM Looks interesting but Does this still require manually inputting 309 lines of data in 3 tables , each with multiple columns ! Quote
jamami Posted Wednesday at 07:26 AM Author Posted Wednesday at 07:26 AM If it does require manual input I suspect the default tableay be the quicker method as fairly easy to type and tab down Quote
BIGAL Posted Thursday at 12:01 AM Posted Thursday at 12:01 AM I think we are struggling to see what you want, if you type 1-2-3 as entry its easy to split it apart based on the "-" into 3 variables . Maybe make a movie if you don't want to post the block. Quote
jamami Posted Thursday at 12:52 PM Author Posted Thursday at 12:52 PM Hi This is a pretty complex block attached. All the parts are spaced out at mo while I am getting things working, once done they are all moved in line. We make beams 2,3,4,5&6m lengths. To make up 7m we use 4+3, to make up 8 we use 5+3, 9-5+4, 10-6+4, ....13-6+4+3 etc etc. i have defined the available viz states Issue is we terminate the beam ends in 1 of 3 ways also we run beams lengths upto 50m at times. Only 1 viz state allowed in autocad (although i did see a link containing a block with multiple viz states but i think that involves some pretty high end programming skills), so I have been playing with using dummy parameters. It works well (attached). My issue is that I need to create many many hundreds of lines of data to encompass the full range I am looking for . jam1.dwg Quote
jamami Posted Thursday at 06:15 PM Author Posted Thursday at 06:15 PM Forgot to add I only populated 2m,3m and 14m on the middle drop down to test the movements and visibilities . the other sizes won’t do anything when selected . Quote
BIGAL Posted yesterday at 12:24 AM Posted yesterday at 12:24 AM (edited) There has been some other program requests ignoring dynamic for moment that take say 13 and work out the beams to make a 13m length. It looks like your doing that or is that why you want a look up table, so get 1-1-2-3 etc You can normally get at any property in a dynamic block so you could skip the select length and enter a length value then the block would be updated. I can see what your using. So using the great program by Lee-mac Dynamic block.lsp you can set say the correct visibilty. Just a question would you be happy using a row function much easier than trying to do some 50+ visibility states. 50 = 8 x 6m + 1 x 2m length so how would that be done as a look up ? 6-6-6-6-6....... Much easier to just make as a row of 6 plus a 2. Same with setting correct end. Have a look at video. Do windows.mp4 Edited yesterday at 12:27 AM by BIGAL Quote
BIGAL Posted yesterday at 02:04 AM Posted yesterday at 02:04 AM (edited) This hopefully will make a list of sizes needed. Limited testing, it needs a check for odd numbers added but just did it quick. Odd numbers will need one less even number size and two other sizes to make answer. But its a start. Some one may have a program already. Just test with even numbers. I can see a pattern in the answers for values that have 1 as remainder so will think more. Ok found it start at 7 and every + 6, 7 13 19 25 etc. gives a remainder of 1. (defun c:wow ( / len 6s 5s 4s 3s 2s 6d 5d 4d 3d 2d) (setq len (getint "\nEnter length ")) (setq 6s 0 5s 0 4s 0 3s 0 2s 0) (setq 6d (/ len 6)) (if (>= 6d 1) (progn (setq 6s (fix 6d)) (setq diff (- len (* 6s 6))) (if (= diff 1) (progn (setq len (- len (* (- 6s 1) 6))) (setq 6s (- 6s 1)) ) (setq len (- len (* 6s 6))) ) ) ) (setq 5d (/ len 5)) (if (>= 5d 1) (progn (setq 5s (fix 5d)) (setq len (- len (* 5s 5))) ) ) (setq 4d (/ len 4)) (if (>= 4d 1) (progn (setq 4s (fix 4d)) (setq len (- len (* 4s 4))) ) ) (setq 3d (/ len 3)) (if (>= 3d 1) (progn (setq 3s (fix 3d)) (setq len (- len (* 3s 4))) ) ) (setq 2d (/ len 2)) (if (>= 2d 1) (progn (setq 2s (fix 2d)) (setq len (- len (* 2s 4))) ) ) (princ (setq lst (list 6s 5s 4s 3s 2s))) (princ) ) Edited yesterday at 07:49 AM by BIGAL Quote
BIGAL Posted 8 hours ago Posted 8 hours ago (edited) As I said previously I believe would be much easier to just enter length and end types. Draw correct shape or use multiple dynamic blocks rather than trying to put it all into one block. I exploded your block with different lengths and start to see patterns. There is another post at the moment that has asked about changing nested dynamic blocks changing each block individually. I am looking at that. Using a DCL for input of data may be the way to go hence the movie showing input data which includes right and left edges. One thing I noticed is that if you say 5m length it makes a 3m+2m lengths structure, so that leads me on to the next step, I can make a Excel say 2-50 using the code I provided it will make the "howmany" 6x 5x 4x 3x 2x etc you can then change so a 8 will become 2x4m (0 0 2 0 0) or a 5+3m (0 1 0 1 0) your choice then can read the Excel for matching lengths, then ask about end types. Or put the sizes into the lisp code. Edited 8 hours ago by BIGAL Quote
jamami Posted 3 hours ago Author Posted 3 hours ago The block jam1 works well for 2.3 and 14m and provides the flexibility to change length, lhs end type and rhs end type. it is a shame that acad do not provide inherent multiple visibility parametrs as the workaround is quite clunky and labour intensive .it is also unfortunate that data cannot be pasted or scripted into lookup tables. the workaround doesn’t work with block property table. I have seen a website that provides an addin to allow multiple visibility parameters and have looked at a block created with this that works well. Did you say Lee Mack also has a routine to do this ? Because there are several other permutations I need to include I Ithink you are correct regarding the use of multiple dynamics blocks, this requires a few more clicks to use but will ultimately save a lot of time having not to explode the block and adjust the contents . . the data generation in Excel is simple , putting the data into lookup tables is where I am struggling as it requires manually entering 1500 items of data into separate cells . So much easier with block properties table where it is one operation using simple cut paste . This is why I am now preparing multiple dynamic blocks and splitting out the various structural element types . Thank you for your help with this I will spend some time and try to understand the lisp provided . Quote
BIGAL Posted 2 hours ago Posted 2 hours ago (edited) have another look at the video, it starts with overall sizes, then gets deeper asking for edge type, the next step is how many window panes hor & ver then the size of the panes. So in your case I exploded the sample block and started to get into the other dynamic blocks, there is no problems inserting a dynamic block then popping up the visibility choices to what you want it set to. I am happy to help. so have a think about an approach first step would be the top row matching visibility lengths. Next step would be the left and right edges type may be different. then central columns. Here is some code if you explode your block so now have separate dynamic blocks, just pick one and a dcl will be made displaying the visibility options. Ok save the Multi radio buttons and Dynamic block get put lee mac to a support path as they are autoloaded. Save this code and appload it etc (defun insdyne ( / pt obj lst ans) (if (not LM:setdynpropvalue )(load "Lee-mac Dynamic block get-put")) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (setq obj (vlax-ename->vla-object (car (entsel "\nPick a dynamic block ")))) (setq visval (LM:getvisibilityparametername obj)) (setq lst (LM:getdynpropallowedvalues obj visval)) (setq lst (cons "Please choose" lst)) (if (not AH:Butts)(load "Multi Radio buttons.lsp")) (if (not AHbut)(setq AHbut 1)) (setq ans (ah:butts 1 "v" lst)) (LM:SetVisibilityState obj ans) (princ) ) (insdyne) So pick the truss displayed, the visibility for that block are displayed and you choose. Dynamic block get-put Lee-mac.lspMulti radio buttons.lsp Edited 2 hours ago by BIGAL Quote
jamami Posted 1 hour ago Author Posted 1 hour ago the dcl seems to show the same thing as the visibility drop down box ? is the only difference multiple radio buttons. Vs a list box ? Quote
jamami Posted 1 hour ago Author Posted 1 hour ago programme for multiple vis sates is called visibility-add-eng_1_6.lsp looks very (very) useful.. multiple visibility states and examples Quote
jamami Posted 47 minutes ago Author Posted 47 minutes ago the app shown in the video looks superb, we really need something like this.....however despite significant cad experience have very little programming knowledge outside of VB. Chat GPT suggested the only way to add data to the lookup table was using a C# programme as lisp was unable to do it? using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Runtime; using System; using System.Collections.Generic; using System.IO; using System.Linq; [assembly: CommandClass(typeof(AutoCAD_CSVImport.MyCommands))] namespace AutoCAD_CSVImport { public class MyCommands { [CommandMethod("ImportLookupTable")] public void ImportLookupTable() { // File path to your CSV string filePath = @"C:\path_to_your_file.csv"; // Check if the file exists if (!File.Exists(filePath)) { Application.ShowAlertDialog("File not found: " + filePath); return; } // Read CSV file List<string[]> data = ReadCSV(filePath); // If there is data if (data.Count > 0) { Document doc = Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Transaction tr = db.TransactionManager.StartTransaction(); try { // Open the Block Table for writing BlockTable blockTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); BlockTableRecord blockTableRecord = (BlockTableRecord)tr.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite); // Loop through the CSV data foreach (var line in data) { string code = line[0]; string field1 = line[1]; string field2 = line[2]; string field3 = line[3]; string field4 = line[4]; string field5 = line[5]; // Insert or update data into a Dynamic Block or a Lookup Table // (Assuming you already have a dynamic block setup) // This is where you would link to your Lookup Table or Dynamic Block // For now, we're just printing out the data Application.ShowAlertDialog($"Adding: {code}, {field1}, {field2}, {field3}, {field4}, {field5}"); } // Commit the transaction tr.Commit(); } catch (Exception ex) { Application.ShowAlertDialog("Error: " + ex.Message); } finally { tr.Dispose(); } } } // Helper method to read CSV private List<string[]> ReadCSV(string path) { var data = new List<string[]>(); try { using (var reader = new StreamReader(path)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); string[] values = line.Split(','); // Add the data to list (excluding empty lines) if (values.Length > 0) { data.Add(values); } } } } catch (Exception ex) { Application.ShowAlertDialog("Error reading file: " + ex.Message); } return data; } } } i have attached the original block that i am trying to update with alternative ends using multiple vis states. There is a pattern in the viz states after 12m s shown below. Adding 3 options for the ends creates 9 x the number of existing visibility states. A DCL is definitely the way to go as I imagine we could use this to produce the plans and elevations (also similar dynamic blocks) simultaneously. I have a concern that block distribution/sharing would be more complex if using an in-house dcl. jam3.dwg 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.