Read a Dynamic Block Properties Table and Fill out a Combo Box

Read a Dynamic Block Properties Table and Fill out a Combo Box

krkeene
Enthusiast Enthusiast
754 Views
7 Replies
Message 1 of 8

Read a Dynamic Block Properties Table and Fill out a Combo Box

krkeene
Enthusiast
Enthusiast

Using AutoCAD 2024 Visual Studio and C#, I have created a Tool Palette with a Control Form in it.  The Control Form has a list box that reads a list of drawings from a database and points to drawing files on our network.  If I select an item from this list box, AutoCAD is able to locate the corresponding DWG file that is a dynamic block of a fastener (screw).  These fastener drawings have a dynamic block table with visibility states for Top View, Side View Solid, Side View Hidden, etc.  If I insert the fastener drawing into my current drawing, it works great.  I have the triangle icon that I can select the dynamic block table and make my selections to get the view that I want. 

 

What I’m looking for help with is: 1) When a fastener is selected in the Tool Palette Control Form, I want to read the dynamic block properties table from the target drawing located on the network, that will be inserted, and then populate the columns into drop-down combo boxes in the Control Form.  2) Once the combo boxes have options, selections can be made for Orientation (Top or Side), Head (Solid or Hidden), Shaft (Solid or Hidden), and Head Rotation (Point to Point or Flat).  3) Once selections are made, the dynamic block is inserted into the current drawing using the appropriate visibility state based on the selections. 

 

I’ve been struggling with writing the code to get to the Dynamic Block Properties Table.  I need to locate the drawing, which I’ve been able to do, but extracting the data from the Dynamic Block Properties Table and then knowing how to populate the combo-boxes has been my problem.  Any pointers in the right direction would be greatly appreciated. 

0 Likes
755 Views
7 Replies
Replies (7)
Message 2 of 8

krkeene
Enthusiast
Enthusiast

I have successfully got the Dynamic Block table properties extracted and available in my code.  I've also been able to concatenate the combo-box values into a string so I can call the Visibility State during the Insert of the block into a drawing.  

 

Now my problem is figuring out how to use the Visibility State Name during the insert command.  Is this possible?

 

0 Likes
Message 3 of 8

CodeDing
Advisor
Advisor

I believe this thread would be better helped in the .NET forum. But an admin would have to move it.

 

Best,

0 Likes
Message 4 of 8

krkeene
Enthusiast
Enthusiast

It was originally in the .NET forum, but I had 0 replies, so I contacted someone directly at Autodesk and they moved it over here.  

Message 5 of 8

CGBenner
Community Manager
Community Manager

@CodeDing 

Hi, the post was moved here as this is the General Customization forum, and I was hoping to get more visibility on the question.  Thank you.  🙂

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!


Chris Benner
Community Manager

Message 6 of 8

pendean
Community Legend
Community Legend

@krkeene wrote:

...Using AutoCAD 2024 Visual Studio and C#, I have created a Tool Palette with a Control Form in it....
It was originally in the .NET forum, but I had 0 replies, so I contacted someone directly at Autodesk and they moved it over here.  


It probably got zero replies as the ask may be too much for an end user like you to do all for free?

I'd ask for it to be moved back, you provide a sample DWG file with the content required be in it, share that TP and the code behind your control form so they can use it to show an attempt at solving the issue yourself so someone can build on it. Pictures alone go nowhere if you want free help. Sorry.

 

Another option: offer to pay someone to do the heavy programming lifting for you as a separate post over here https://forums.autodesk.com/t5/community-classifieds/bd-p/119  

0 Likes
Message 7 of 8

CodeDing
Advisor
Advisor

@krkeene ,

 

I don't think I could personally help much more, but If I were to explore the coding further, I would start with this class here:

 

https://help.autodesk.com/view/OARX/2023/ENU/?guid=OARX-ManagedRefGuide-Autodesk_AutoCAD_DatabaseSer... 

 

Hopefully that can get you on a better direction.

Best,

0 Likes
Message 8 of 8

Sea-Haven
Mentor
Mentor

I do this but in lisp, insert the dynamic block 1st,  read its dynamic visibilities and choose using a DCL which one then set the visibility of the block the end user does not really see anything out of the ordinary. Its pretty straight forward.

 

;; Sets the Visibility Parameter of a Dynamic Block (if present) to a specific value (if allowed)
;; Get Visibility Parameter Name  -  Lee Mac
;; Returns the name of the Visibility Parameter of a Dynamic Block (if present)

(defun insdynv (blkname / pt obj lst ans)
(if (not LM:setdynpropvalue )(load "Lee-mac Dynamic block get-put"))
(setq pt (getpoint "\nPick a pt for block "))
(command "-insert" blkname "s" 1.0  pt 0)
(setq obj (vlax-ename->vla-object (entlast)))
(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)
)

 Uses lee-mac dynamic block properties.

Should be enough regarding method to do in .net. 

SeaHaven_0-1707453290233.png

 

0 Likes