Controlling a Specific Block Automatically After Placement

Controlling a Specific Block Automatically After Placement

cpcpatrickcardine
Explorer Explorer
453 Views
3 Replies
Message 1 of 4

Controlling a Specific Block Automatically After Placement

cpcpatrickcardine
Explorer
Explorer

I am currently working on a simple stair plugin as a side project for Autocad. As of now I can draw a pline connecting two points as stairs and I can specify constraints like the start and end positions, or the tread rise or run. This is just the base of what I hope becomes a more useful plugin with many features.

 

As I am getting further and further into this project I am realizing that eventually I will be drawing complicated 3d stairs and possible curves and winders and all that jazz. It would be a pain if you couldn't modify them after making them. Obviously you could simply edit them in basic Autocad, but I was wondering if I could create a block that contained my stair and have specific code for editing it. Something where the user could enter new tread rise values or tread run values and such to modify their design. I understand if this is possibly extremely complicated, but I am willing to put the time in to learn it.

 

As you can probably tell I am new to plugin development so any help you could give would be greatly appreciated. Oh and I'm coding this in c#. 

Thanks!

0 Likes
Accepted solutions (1)
454 Views
3 Replies
Replies (3)
Message 2 of 4

norman.yuan
Mentor
Mentor

Based on your description, it sounds like that if you use block to present a stair, you might want to consider using dynamic block: just design the block manually to make the tread rise/run value as dynamic properties; then your plugin can place the dynamic block reference and manipulate the dynamic properties accordingly. If this could meet your requirement, the code would not be "extremely complicated". Rather, it would be fairly simple: creating blockreference and setting its dynamic property values. Of course, designing an appropriate dynamic block is outside your plugin coding.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 4

cpcpatrickcardine
Explorer
Explorer

I did consider this as another option, but the general reason for me creating this plugin is because I want more functionality than the dynamic block will give me. As of right now, the dynamic block would encapsulate all of the features I have, but in the future I plan on having many more features that would not be easily manipulated with a dynamic block, at least from what I know about them. For example, I was thinking of adding some form of path following to the stair so that you could create a curve in 3d space and have the stair follow it. This is pretty far in the future, but I doubt I could implement that with a dynamic block. 

 

Also I was hoping I could create draggable points so you don't have to input new coordinates but can intuitively manipulate the stair. I don't know how much control you have over dynamic blocks however. 

 

Is there a way to easily add functionality to dynamic blocks through code? 

Thanks!

0 Likes
Message 4 of 4

norman.yuan
Mentor
Mentor
Accepted solution

Well, if dynamic block will not meet your eventual goal, then you might look into other suitable software than plain AutoCAD, such AutoCAD Arch, or Revit, or other third party AutoCAD add-on apps. Since you said "simple stair" plugin, thus the suggestion of dynamic block. Still, if it does meet your current need, you can use it without invent too much effort, as I said, except for the dynamic design, the code to handle it in your plugin would fairly easy.

 

There is no API exposed to programmatically define a dynamic block. So, the block has to be created manually. The code would only manipulate the dynamic properties.

 

As for draggable point (or line, or whatever entity), if you have ever coded Jig/Transient Graphics, you would know that in most cases you could create a temporary (transient) graphics that follows the mouse move to provide user a visual "illusion" that an entity is dragged. Often, the entity in interest itself is not actually moved at all until the dragging of ghost image is done. So, yes, you can write code to let user to "drag" any part of the stair, be it a block reference or not. You can even add your own custom grip to your stair and write code to control how that grip to be dragged. However, topic on this in AutoCAD .NET API is a bit of advanced.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes