See the top rated post in this thread. Click here

Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: Create Dynamic Block

  1. #1
    I could stop if I wanted to
    Join Date
    2003-03
    Location
    Alberta
    Posts
    260
    Login to Give a bone
    0

    Question Create Dynamic Block

    I'm trying to write a function that will create a dynamic block definition for me. I can create the block and geometry no problem. I have no idea where to start for adding dynamic properties (parameters and actions) to the block definition. Any suggestions?

  2. #2
    I could stop if I wanted to artisteroi's Avatar
    Join Date
    2007-02
    Location
    Tampa, FL
    Posts
    271
    Login to Give a bone
    0

    Default Re: Create Dynamic Block

    Quote Originally Posted by bweir View Post
    I'm trying to write a function that will create a dynamic block definition for me. I can create the block and geometry no problem. I have no idea where to start for adding dynamic properties (parameters and actions) to the block definition. Any suggestions?
    last I heard the block editor deactivates all scripting while it is enabled. So you can't actually make the dynamic properties using a secondary software. You have to do it manually. Sorry

  3. #3
    I could stop if I wanted to
    Join Date
    2003-03
    Location
    Alberta
    Posts
    260
    Login to Give a bone
    0

    Default Re: Create Dynamic Block

    Maybe I should clarify. I'm not using scripts or the block editor. I'm trying to develop a function using the VB.NET API.

  4. #4
    I could stop if I wanted to artisteroi's Avatar
    Join Date
    2007-02
    Location
    Tampa, FL
    Posts
    271
    Login to Give a bone
    0

    Default Re: Create Dynamic Block

    Quote Originally Posted by bweir View Post
    Maybe I should clarify. I'm not using scripts or the block editor. I'm trying to develop a function using the VB.NET API.

    my bad. By script I mean any type of automatic programming, script, lisp, vb, even dot.net. It's all scripting of one sort or another. So the block editor shuts it off. becuase the block editor is a script program as well, it just uses a gui instead of code processing. I don't think it can be done.

  5. #5
    I could stop if I wanted to
    Join Date
    2003-03
    Location
    Alberta
    Posts
    260
    Login to Give a bone
    0

    Default Re: Create Dynamic Block

    Sorry, again I'm NOT using the block editor. I define a BlockTableRecord and add it to the BlockTable of the database. Something like this...
    Code:
            Dim Blocks As BlockTable
            Dim ObjId As ObjectId
            Dim Block As BlockTableRecord
            Dim Trans As Transaction
            Dim BasePoint As Point2d
    
            Trans = Database.TransactionManager.StartTransaction
            Try
                Blocks = Trans.GetObject(Database.BlockTableId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite, False, False)
                ObjId = Blocks.Add(New BlockTableRecord)
    
                Block = Trans.GetObject(ObjId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite, False, False)
                Block.Name = "MyBlockNameHere"
                Block.Units = Autodesk.AutoCAD.DatabaseServices.UnitsValue.Undefined
                Block.BlockScaling = Autodesk.AutoCAD.DatabaseServices.BlockScaling.Uniform
                Block.Comments = "This block is generated automatically and should not be edited."
                Block.Explodable = False
    
                Trans.AddNewlyCreatedDBObject(Block, True)
    
                        ' Code to add geometry goes here...
    
                        ' Need some other code here to add dynamic properties???
    
           Catch ex As Autodesk.AutoCAD.Runtime.Exception
                Application.ShowAlertDialog("CreateBlock" & vbNewLine & ex.ToString)
                Block = Nothing
                Trans.Abort()
            Finally
                Trans.Dispose()
                Trans = Nothing
                Database = Nothing
            End Try
    Last edited by bweir; 2008-02-05 at 10:04 PM. Reason: Corrected Type Names

  6. #6
    I could stop if I wanted to artisteroi's Avatar
    Join Date
    2007-02
    Location
    Tampa, FL
    Posts
    271
    Login to Give a bone
    0

    Default Re: Create Dynamic Block

    Right Right.
    What I mean is that you can't add parameters and actions to a block without accessing the block editor. Those items don't exist in standard model space. you must access the block editor to create a dynamic block.
    the 'bedit' & name of block reference commands will open the editor but as soon as it is open the .net protocals will be deactivated. The code will just stop or truncate. Probably crash autocad. Or it will say you can't call the block editor while a command is active, the command being the .net script.
    if you try to add a parameter or action to a block outside the block editor you will get a error message that says "that command is only allowed inside the block editor". Think of the block editor as a sort of sub-model space. what is possible in the block editor like actions and parameters are imposible in model space. and what is possible in model space like macros and scripting is impossible in block editor space.
    It would be the same as using vba to write lisp code. you can't use one code to write another. It would cause a rift in the space-time continuum.
    I could be wrong so if you can make it work please let us know. But I think you are fighting an impossible battle.

  7. #7
    I could stop if I wanted to
    Join Date
    2003-03
    Location
    Alberta
    Posts
    260
    Login to Give a bone
    0

    Default Re: Create Dynamic Block

    Is this not exposed in the .NET API somewhere? And. Yes you can run scripts and Lisp and .NET commands from inside the Block Editor. I just tried it and everything worked fine, unless the command is marked not to run in the Block Editor which you can do with the <CommandMethod(...)> attribute in .NET.

    A dynamic block is stored in the BlockTable like any other block (unless I missed something). This being the case, how do you add dynamic properties to a BlockTableRecord to make it a dynamic block? Does it have something to do with the DynamicDimensionDataCollection and how would this apply to the BlockTableRecord.
    Last edited by bweir; 2008-02-06 at 04:06 PM.

  8. #8
    I could stop if I wanted to
    Join Date
    2003-03
    Location
    Alberta
    Posts
    260
    Login to Give a bone
    0

    Default Re: Create Dynamic Block

    I've been inspecting some dynamic blocks I've created. It looks like the dynamic property information might be stored in the blocks ExtensionDictionary. Can anybody help confirm this for me?

  9. #9
    I could stop if I wanted to artisteroi's Avatar
    Join Date
    2007-02
    Location
    Tampa, FL
    Posts
    271
    Login to Give a bone
    0

    Default Re: Create Dynamic Block

    Quote Originally Posted by bweir View Post
    Is this not exposed in the .NET API somewhere? And. Yes you can run scripts and Lisp and .NET commands from inside the Block Editor. I just tried it and everything worked fine, unless the command is marked not to run in the Block Editor which you can do with the <CommandMethod(...)> attribute in .NET.

    A dynamic block is stored in the BlockTable like any other block (unless I missed something). This being the case, how do you add dynamic properties to a BlockTableRecord to make it a dynamic block? Does it have something to do with the DynamicDimensionDataCollection and how would this apply to the BlockTableRecord.
    great you got scripting to work inside the block editor. I guess autodesk was wrong again, they were the ones who said the editor would shut off scripting. Kewl

    the dynamic blocks are stored in the btr just like other blocks. when you run the code check block for "isdynamic = true" and then "blockref.getdynamicproperties" will allow you to change them. But I don't know how you would create them since I never tried to run a script inside the block editor since I was told it was impossible.

  10. #10
    I could stop if I wanted to
    Join Date
    2003-03
    Location
    Alberta
    Posts
    260
    Login to Give a bone
    0

    Default Re: Create Dynamic Block

    Quote Originally Posted by artisteroi View Post
    great you got scripting to work inside the block editor. I guess autodesk was wrong again, they were the ones who said the editor would shut off scripting. Kewl
    I think what you are referring to regarding scripting is if you run a script and that script executes the BEDIT command, the script will stop until the BEDIT command has finished (that is the Block Editor has closed).

    Quote Originally Posted by artisteroi View Post
    the dynamic blocks are stored in the btr just like other blocks. when you run the code check block for "isdynamic = true" and then "blockref.getdynamicproperties" will allow you to change them. But I don't know how you would create them since I never tried to run a script inside the block editor since I was told it was impossible.
    AND Again I'm not using the Block Editor to create the block, I'm using a program I've written my self to create and edit the block. I need to know what data I need to add to the block definition to make it a dynamic block. I've found that dynamic blocks have a entry in the ExtendedDictionary of the block named ACAD_ENHANCEDBLOCK. I'm assuming this is the data that defines the dynamics but I don't know what to put in it.

Page 1 of 3 123 LastLast

Similar Threads

  1. How to create dynamic block in 3d?
    By radosak368138 in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2013-10-30, 05:13 PM
  2. Create a dynamic block with multiple insertion points
    By danielk in forum Dynamic Blocks - Technical
    Replies: 18
    Last Post: 2012-09-07, 08:38 AM
  3. How To Create Dynamic Block With Attributes - Drawing Title
    By omorah in forum Dynamic Blocks - Technical
    Replies: 1
    Last Post: 2012-08-09, 02:36 AM
  4. How to create a dynamic attributed block
    By andy.89024 in forum Dynamic Blocks - Technical
    Replies: 10
    Last Post: 2006-07-05, 07:19 PM
  5. Create new Dynamic Block via editing a Block within another drawing file
    By pbrumberg in forum Dynamic Blocks - Technical
    Replies: 2
    Last Post: 2006-01-10, 05:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •