Can I apply material to an object inside an AutoCAD block using C#?

Can I apply material to an object inside an AutoCAD block using C#?

acadadmin3KNUF
Advocate Advocate
348 Views
1 Reply
Message 1 of 2

Can I apply material to an object inside an AutoCAD block using C#?

acadadmin3KNUF
Advocate
Advocate

Hello to all:

 

I need a way to assign materials to sufaces and 3d Solids in AutoCAD blocks programmatically.  I can stretch my object's lengths and flip them from one side to the other using dynamic block parameters, but now I'm told we need to have the ability to change material assignments in a similar fashion.  These are conveyor bed blocks I'm dealing with; the blocks have C-Channels for frame rails, cylinders for rollers, etc.  We need the ability to reach-inside the block definition and change the material assigned to the frame-rails "on-the-fly" without opening the block editor and changing the material assignment on the Properties palette.  Is this possible?

 

Anyone have any experience with this?

0 Likes
349 Views
1 Reply
Reply (1)
Message 2 of 2

Sea-Haven
Mentor
Mentor

I dont do C# but you can get at the block definition in the Block table and should be able to change it there, and maybe do a attsync to update the blocks.

 

(setq blk (tblsearch "BLOCK" "northn"))
((0 . "BLOCK") (2 . "NORTHN") (70 . 0) (10 0.0 0.0 0.0) (-2 . <Entity name: 3d0cfc80>))
(setq b (cdr (assoc -2 blk)))
(vlax-dump-object (vlax-ename->vla-object b))
;   Material = "ByLayer"

 

0 Likes