.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how top revent a block from explode using vb.net

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
ButterFlyShame
1250 Views, 9 Replies

how top revent a block from explode using vb.net

Hello,

I want a specific block name not be exploded using vb.net. Is it possible ?

Thanks in advance.

9 REPLIES 9
Message 2 of 10
cadMeUp
in reply to: ButterFlyShame

Set the 'Explodable' property of the BlockTableRecord to false.

Message 3 of 10
ButterFlyShame
in reply to: cadMeUp

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

 

Message 4 of 10
cadMeUp
in reply to: ButterFlyShame

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

Message 5 of 10
ButterFlyShame
in reply to: cadMeUp

Thank your sir (CadMeUP).

 It worked .

I really appreciate your help here.

Have a good weekend and Merry Christmas.

 

Message 6 of 10
Jeffrey_H
in reply to: ButterFlyShame

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.

You can also find your answers @ TheSwamp
Message 7 of 10
cadMeUp
in reply to: ButterFlyShame

You too!

Merry Christmas!

 

Merry Christmas to all!

Message 8 of 10
ButterFlyShame
in reply to: Jeffrey_H

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,

 

 

Message 9 of 10
cadMeUp
in reply to: ButterFlyShame

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.

Message 10 of 10
ButterFlyShame
in reply to: cadMeUp

I am all good gentlemen.Thanks for teaching.

Regards,

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost