Jump to content

Recommended Posts

Posted

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 ?

 

 

Screenshot 2025-07-29 184159.png

Posted

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.

 

image.png.8618990182eb2c31658132ca1bca85fb.png

 

 

 

 

 

 

Posted

Looks interesting but Does this still require manually inputting 309 lines of data in 3 tables , each with multiple columns !

 

 

Posted

If it does require manual input I suspect  the default tableay be the quicker method as fairly easy to type and tab down

Posted

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.

Posted

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

Posted

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 . 

Posted (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. 

 

image.png.0f7efd833bbdd4663db1bb646db0a6f3.png

 

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.

 

 

 

 

 

Edited by BIGAL
Posted (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 by BIGAL
Posted (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 by BIGAL
Posted

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 .

Posted (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. 

image.png.b3d21cbced3c7c979603bd8a396bbd17.png

 

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.

 

image.png.0130ce146a47cba602d53679e318df1c.png

 

Dynamic block get-put Lee-mac.lspMulti radio buttons.lsp

 

Edited by BIGAL
Posted

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 ?

Posted

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.

 

image.thumb.png.6fcb55ce47525a7cd43b92991b5e7d89.png

 

 

jam3.dwg

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...