Stay organized with collections
Save and categorize content based on your preferences.
blockly > WorkspaceSvg > newBlock
WorkspaceSvg.newBlock() method
Obtain a newly created block.
Signature:
newBlock(prototypeName: string, opt_id?: string): BlockSvg;
Parameters
Parameter |
Type |
Description |
prototypeName |
string |
Name of the language object containing type-specific functions for this block. |
opt_id |
string |
(Optional) Optional ID. Use this ID if provided, otherwise create a new ID. |
Returns:
BlockSvg
The created block.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eWorkspaceSvg.newBlock()\u003c/code\u003e method creates a new block within a workspace based on a specified prototype.\u003c/p\u003e\n"],["\u003cp\u003eIt takes the prototype name and an optional ID as input, using the provided ID or generating a new one if not specified.\u003c/p\u003e\n"],["\u003cp\u003eThe method returns a \u003ccode\u003eBlockSvg\u003c/code\u003e object representing the newly created block, ready for further manipulation or use within the workspace.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [WorkspaceSvg](./blockly.workspacesvg_class.md) \\\u003e [newBlock](./blockly.workspacesvg_class.newblock_1_method.md)\n\nWorkspaceSvg.newBlock() method\n------------------------------\n\nObtain a newly created block.\n\n**Signature:** \n\n newBlock(prototypeName: string, opt_id?: string): BlockSvg;\n\nParameters\n----------\n\n| Parameter | Type | Description |\n|---------------|--------|--------------------------------------------------------------------------------|\n| prototypeName | string | Name of the language object containing type-specific functions for this block. |\n| opt_id | string | *(Optional)* Optional ID. Use this ID if provided, otherwise create a new ID. |\n\n**Returns:**\n\n[BlockSvg](./blockly.blocksvg_class.md)\n\nThe created block."]]