1

I would like to pass parameter values to an Autocad parametric block in a .net application. A simple parameter is "d1" (distance).

I am writing a kind of complex asp.net product comfigurator applciation that shuold generate a 2D dxf file based on the user input. I use Unity webgl to render the 3D in the webpage, but i also need to create a dxf file at runtime because a Autocad compatible 2D section is in the requirements.

To avoid to create the section from scratch I found that parametric blocks could be a solution: a designer provides me a very complex parametric block and i pass to it the parameters at runtime so that the output file could be donwloaded.

Somehow two tasks are needed:

1) pass the parameters to a parametric block

2) save it to simple dxf (i am not interested it is a parametric block after parameters have been passed)

I was not able to figure out to perform this in .net.

UnDiUdin
  • 14,924
  • 39
  • 151
  • 249
  • I found I was able to edit block scale, and other properties, but in the end couldn't work with parametric blocks from the APIs. See https://stackoverflow.com/questions/19290030/is-it-possible-to-edit-block-attributes-in-autocad-using-autodesk-autocad-intero – reckface Sep 27 '16 at 09:29
  • @reckface could you please provide me a poitner to APIs? What they are exactly? I can not understand from the question you linked why parametric blocks are not usable. Thanks. – UnDiUdin Sep 27 '16 at 09:58
  • I used the block.GetDynamicBlockProperties(), then iterated through the properties and tried to set values, but there was no effect on the block. I am able to _document.ModelSpace.InsertBlock(coordinate.Point, name, scale, yScale, scale, angleInRadians) and then scale it, but that's all you get – reckface Sep 27 '16 at 10:18

1 Answers1

0

To change the parameters of your dynamic block, you can use GetDynamicBlockProperties to get the properties, then you can change the value on each property.

There is an example in VBA here: http://visiblevisual.com/jupgrade/index.php/autocad-vb-vba/9-insert-dynamic-block.

To save your drawing to a DXF file, you can use Document.SaveAs(fileName, AcSaveAsType.ac2000dxf)

However, if you're building a web site, you should use the Forge Design Automation API (formerly known as AutoCAD I/O API) instead of driving an AutoCAD instance (this is not reliable and the AutoCAD EULA does not allow you to do this). You can also use Teigha.

Maxence
  • 12,868
  • 5
  • 57
  • 69