Hello,
I want a specific block name not be exploded using vb.net. Is it possible ?
Thanks in advance.
Solved! Go to Solution.
Solved by cadMeUp. Go to Solution.
Thanks for your time to reply CadMeUp.
I googled 'explodable' property. Autodesk help says:
""" To access this property, use the IAcadBlock3 interface. "" . Which I don't know what " IAcadBlock3 " means.
in your comment you mentioned about "BlockTableRecord" . I don't know that neither.
Below is my code which does not work. Could you or somebody else correct it.
Sub test1() Dim Blockobj As Autodesk.AutoCAD.Interop.Common.AcadBlock Dim BlockRefObj As Autodesk.AutoCAD.Interop.Common.AcadBlockReference Dim Startpnt(0 To 2) As Double Startpnt(0) = 0 Startpnt(1) = 0 Startpnt(2) = 0 BlockRefObj = ThisDrawing.ModelSpace.InsertBlock(Startpnt, "c:\harris\arrow.dwg", 1, 1, 1, 0) For Each Entry In ThisDrawing.ModelSpace With Entry If StrComp(.EntityName, "AcDbBlockReference", 1) = 0 Then If Entry.Name = "arrow" Then Entry.Explodable = False End If End If End With Next Entry End Sub
No need for the For Each loop:
For Each Entry In ThisDrawing.ModelSpace
Something like:
...
BlockRefObj = ThisDrawing.ModelSpace.InsertBlock(Startpnt, "c:\harris\arrow.dwg", 1, 1, 1, 0)
Blockobj = ThisDrawing.Blocks.Item("arrow")
Blockobj.Explodable = False
For developing in net you might want to check out the info at these links:
http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1911627
http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html
Thank your sir (CadMeUP).
It worked .
I really appreciate your help here.
Have a good weekend and Merry Christmas.
To keep a user from changing back...........
To change the value back to true, I think the only way is through the block editor.
So you could add a event handler for CommanedEnded and check for BCLOSE then make sure it is still true
and change back if not.
Thanks Jeffrey for your time and advice.
I am not very expert.I learned vb.net just by try and error.
Yes your advice is very nice. I am going to take it and this way user can't change explodable property back. Never thought of it, that way.
But I read somewhere having event handler will have impact on autocad because it always looking for what user is doing. Is that so? Becuase we are dealing with huge drawings.That was one the reasons we didnn't want users to explode blocks.
I am just worry adding an event handler and leaving it open , have impact on drawing process.
Looking for answer please.
Regards,
Depending on what you are doing in your event handlers the impact is usually very minimal compared to the benefits that you get. You're most likely not going to see much impact at all if any. Monitoring events is very useful and sometimes the only way to achieve certain results. Jeffrey's suggestion should work well.
You could also keep users out of the blockeditor altogether with the 'BLOCKEDITLOCK' system variable set to 1, You can also monitor if someone tries to change the value of 'BLOCKEDITLOCK' and change it back to 1 which disallows opening into the blockeditor, something like the following C# code (coding is different in vb but process and objects are similar):
private void AcadApp_SystemVariableChanged(Object sender, Autodesk.AutoCAD.ApplicationServices.SystemVariableChangedEventArgs e)
{
if (e.Name == "BLOCKEDITLOCK")
{
short varVal = (short)AcadApp.GetSystemVariable("BLOCKEDITLOCK");
if (varVal != 1)
{
Document doc = AcadApp.DocumentManager.MdiActiveDocument;
AcadApp.SetSystemVariable("BLOCKEDITLOCK", 1);
doc.Editor.WriteMessage("\nCan't change value of BLOCKEDITLOCK! reset to 1");
}
}
}
Just keep in mind whatever route you go to keep users from editing your blocks they can bypass your measures to prevent them from being edited and altered. All someone would have to do is start up AutoCAD into a profile that doesn't load your net module files and they have all the access they need to edit your blocks, none of the preventable measures would be there. There isn't any way that is going to be 100% full proof.