How can I insert a block with attributes using VB.net without using jigs? Currently Jigs requires a PromptResult and I want to just pass the block name and attribute without having to respond to the PromptResult.
Solved! Go to Solution.
How can I insert a block with attributes using VB.net without using jigs? Currently Jigs requires a PromptResult and I want to just pass the block name and attribute without having to respond to the PromptResult.
Solved! Go to Solution.
Solved by norman.yuan. Go to Solution.
Hi rhaywood
I done some work with inserting blocks with Attributes some time ago.
Can you expand a bit more on what you need and mean by jigs?
Are you creating the block definition (attributes) in code or only inserting the block and populating the Attributes using code?
Hi rhaywood
I done some work with inserting blocks with Attributes some time ago.
Can you expand a bit more on what you need and mean by jigs?
Are you creating the block definition (attributes) in code or only inserting the block and populating the Attributes using code?
Hi Rod
I not sure if I can help you.
I don't have any experience of jigs if that the problem?
I run code either from the command prompt calling a saved procedure or using a load Form.
I calling up the insertion of the blocks using a Vb.Net insertion procedure and don't get any PromptResult.
So not sure where you are getting the PropmptResult is it coming from the Attributes?
If you insert the block manually do you PropmptResult?
Hi Rod
I not sure if I can help you.
I don't have any experience of jigs if that the problem?
I run code either from the command prompt calling a saved procedure or using a load Form.
I calling up the insertion of the blocks using a Vb.Net insertion procedure and don't get any PromptResult.
So not sure where you are getting the PropmptResult is it coming from the Attributes?
If you insert the block manually do you PropmptResult?
Block can definitely be inserted proggrammatically without Jig, if it is not necessary for waiting user input. Mind you, jig is meant to provide visual hint when the process (inserting) is waiting for user input (position, rotation, scale...), thus the inserting can only be completed(or cancelled) after PropmtResult is returned, when jig is used.
So, I am not quite sure what you want: do you mean that your code can insert a block, but cannot rotate it to a known angle without jig? If the rotation angle is known (or any other inserting data, position, scale...) why there is need for jig?
For example, if all information about inserting a block is known, you can do the inserting like (pseudo-code)
public void InsertBlock(string blkName, Point3d position, double rotation, doubel scale)
{
//Find block definition id, based on block name. insert the block definition, if necessary
....
//Create block referenece
var bref=new BlockReference(blkdefId, position);
// add it to proper space (model or paper)
// add to transaction
//Add attributes, if necessary, based on block defeinition
//Roate it to the known angle (WITHOUT waiting for user input via jig!)
var mt = Matrix3D.Rotation(rotation, Vector3d.ZAxis, position);
Bref.Transform(mt)
Scale3d s=new Scale3d(scale, scale, scale);
Bref.ScaleFactors=s;
// whatever extra work you need to do with this block refernece
}
So, you might want to explain the process from user's point of view step by step and what information about the block is known prior to inserting, and why you think you have to use jig in that case.
Norman Yuan
Block can definitely be inserted proggrammatically without Jig, if it is not necessary for waiting user input. Mind you, jig is meant to provide visual hint when the process (inserting) is waiting for user input (position, rotation, scale...), thus the inserting can only be completed(or cancelled) after PropmtResult is returned, when jig is used.
So, I am not quite sure what you want: do you mean that your code can insert a block, but cannot rotate it to a known angle without jig? If the rotation angle is known (or any other inserting data, position, scale...) why there is need for jig?
For example, if all information about inserting a block is known, you can do the inserting like (pseudo-code)
public void InsertBlock(string blkName, Point3d position, double rotation, doubel scale)
{
//Find block definition id, based on block name. insert the block definition, if necessary
....
//Create block referenece
var bref=new BlockReference(blkdefId, position);
// add it to proper space (model or paper)
// add to transaction
//Add attributes, if necessary, based on block defeinition
//Roate it to the known angle (WITHOUT waiting for user input via jig!)
var mt = Matrix3D.Rotation(rotation, Vector3d.ZAxis, position);
Bref.Transform(mt)
Scale3d s=new Scale3d(scale, scale, scale);
Bref.ScaleFactors=s;
// whatever extra work you need to do with this block refernece
}
So, you might want to explain the process from user's point of view step by step and what information about the block is known prior to inserting, and why you think you have to use jig in that case.
Norman Yuan
OK, now I know you do need jig to get user input for insertion point/rotation. But jig has nothing to do with block name: you can only start a jig (EntityJig, or DrawJig, does not matter here) AFTER the block reference is created (so you can "jig" it show give user visual hint), which means the block name , as a piece of required information has already been used before the jig exists.
Since you asking in developer" forum, I assumed you code your own jig. Are you using a jig developed by someone else that includes a step of asking block name? If you code your own Jig, for example a EntityJig, you can simply pass the block name in the constructor and use that block name to create BlockReference instance before jig dragging.
Unless you show your code, I have no idea why there is need to show PromptResult (meaning a user input) to confirm block name even the block name is already known.
So, my short answer to your question (the title of your post) is, you can insert block anyway you want (with code), using jig or not, depending on what information you already know; there is no need to confirm block name in the jig if the name is already known. If the jig is predefined/existing component, you either live with it, or you write your own.
Norman Yuan
OK, now I know you do need jig to get user input for insertion point/rotation. But jig has nothing to do with block name: you can only start a jig (EntityJig, or DrawJig, does not matter here) AFTER the block reference is created (so you can "jig" it show give user visual hint), which means the block name , as a piece of required information has already been used before the jig exists.
Since you asking in developer" forum, I assumed you code your own jig. Are you using a jig developed by someone else that includes a step of asking block name? If you code your own Jig, for example a EntityJig, you can simply pass the block name in the constructor and use that block name to create BlockReference instance before jig dragging.
Unless you show your code, I have no idea why there is need to show PromptResult (meaning a user input) to confirm block name even the block name is already known.
So, my short answer to your question (the title of your post) is, you can insert block anyway you want (with code), using jig or not, depending on what information you already know; there is no need to confirm block name in the jig if the name is already known. If the jig is predefined/existing component, you either live with it, or you write your own.
Norman Yuan
If you look at the code carefully, the use of 2 jigs in your code (InsertBlockJig and RotateBlockJig) only happens AFTER the block reference is created (which requires block name as input) - exactly as I said previously: jig has nothing to do with the blcok name.
Since you have already pass the block name into the method InsertBlockRotateAndAddAttributesWithJig() method, this line (the bold red portion)
Dim pr AsPromptResult = ed.GetString(blkName)
is completely useless (the retured PromptResult is not used in following code at all). What you need here is only to declare a varaibaler "pr" as PromptResult type. So, change it to
Dim pr As PromptResult
Then you are good.
Norman Yuan
If you look at the code carefully, the use of 2 jigs in your code (InsertBlockJig and RotateBlockJig) only happens AFTER the block reference is created (which requires block name as input) - exactly as I said previously: jig has nothing to do with the blcok name.
Since you have already pass the block name into the method InsertBlockRotateAndAddAttributesWithJig() method, this line (the bold red portion)
Dim pr AsPromptResult = ed.GetString(blkName)
is completely useless (the retured PromptResult is not used in following code at all). What you need here is only to declare a varaibaler "pr" as PromptResult type. So, change it to
Dim pr As PromptResult
Then you are good.
Norman Yuan
Can't find what you're looking for? Ask the community or share your knowledge.