Article | 70000531 |
Type | Wish |
Product | WebJS |
Version | 7005 |
Date Added | 8/20/2015 12:00:00 AM |
Fixed | 7.7007.0.1 (11/20/2015 12:00:00 AM) |
Submitted by | Ilan Sandor |
Summary
I would like to be able to add a block when using the web library through code or through a file. Also I would like for them to have attribute support.
Solution
Four new functions were added in the web library. Using these, the user can add blocks on the runtime, add attributes to blocks and Get/Set the values of these attribuets.
AddBlock(blockname, originPoint)
Add a block object in the blocks collection of the document. If the blockname already exists, the already created block is returned. The function takes the following parameters- blockname: The name of the block to be added.
- originPoint: The origin point of the block to be added.
How to add entities to a block object
After adding the new block, you can add entities to it. Simply call the Add... function you need and pass the block's Entities collection in the end.
Examplevar block = vdcanvas.AddBlock(blockName, [0,0,0]); vdcanvas.AddRect([-1,-1,0], [1,1,0], false, block.Entities); vdcanvas.AddCircle([0,0,0], 1, false, block.Entities);
AddAttribDef(block, height, rotation, tag, value, position)
Adds a new vdAttribDef object to the passed block. The function takes the following parameters- block: The block where the vdAttribDef object will be added.
- height: The height of the text of the attribute in drawing units.
- rotation: The rotation of the text of the attribute in drawing units.
- tag: The tag of the vdAttribDef object.
- value: The value of the vdAttribDef object. This string will be displayed on the blockSymbol.
- position: The position of the attribute in entity coordinates.
GetAttribValue(tag, blockSymbol)
Returns the value of the first attribute matching the tag parameter. The check is no case sensitive. The function takes the following parameters- tag: The tag of the attribute from which to get the value.
- blockSymbol: The block symbol object in which the attributes will be searched for.
SetAttribValue( tag, value, blockSymbol)
Sets the defined value string to the attribute matching the tag parameter. The check is no case sensitive. The function takes the following parameters- tag: The tag of the attribute to set the value.
- value: The value string to set to the matching attribute.
- blockSymbol: The block symbol object in which the attributes will be searched for.