PDA

View Full Version : Solid Block Editing



artisteroi
2008-06-02, 08:02 PM
Has anyone ever tried to edit a solid as a block reference?
My theory is that you should be able to make a primitive solid such as a box and place it inside a block, then edit the block using the api, but I am having trouble finding the solid properties after it is inside the block. I have found lots of info on how to create a solid, or transform a solid using the api, but no luck on how to change a primitive property.
A box has the properties of length, width, and height. But I can't seem locate these in my block.
Anyone up to the challenge?

T.Willey
2008-06-03, 03:02 PM
Where is your code? Are you trying to edit the block reference? If so, you have to edit the block definition where the solid resides.

artisteroi
2008-06-03, 04:28 PM
I am actually trying to edit the solid inside the block refence so I guess yes I am trying to edit the block reference.
I can't find where the solid resides in the block ref. Seems to me it should be something like a get ent.solid3d.properties or something like that. But there doesnt seem to be any entities in the reference that are called solids. Does the api call a solid by another name?
the code master won't let me post code just now (I'll try to get it later). I have to get higher up permissions. Apparently the code is top secret.

T.Willey
2008-06-03, 04:52 PM
You might be able to get the solid object using the the equivalent .Net function of 'nentsel' in lisp. Not sure what it is off hand, but I know there is one.

artisteroi
2008-06-03, 05:58 PM
thats what I thought. I will see if I can find the method. So I need the entity selection, then just cycle through the entiies to find the properties of the solid.

T.Willey
2008-06-03, 06:27 PM
You just need the selection method for nested entities. This will get you the solid object, and you can get all the properties.

Ed Jobe
2008-06-03, 07:38 PM
I can't find where the solid resides in the block ref.

It doesn't. Its in the definition. Use the block ref to get the name of the block, then go to the Blocks collection and get the block. Use its Items collection to get your object to modify.

dmarcotte4
2008-06-05, 10:58 AM
You could try something like this...


public class Commands
{
[CommandMethod("doit")]
public static void doit()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
try
{
AcDb.TransactionManager tm =
HostApplicationServices.WorkingDatabase.TransactionManager;

ObjectId id = acedNEntSelPExTest();

if (!id.IsNull)
{
using (Transaction tr = tm.StartTransaction())
{
Solid3d ob3d = tr.GetObject(id, OpenMode.ForRead, false) as Solid3d;
if (!ob3d.IsNull)
{
ed.WriteMessage(ob3d.GetRXClass().Name);
}
}
}
}
catch (SystemException ex)
{
ed.WriteMessage("\n" + ex.Message);
ed.WriteMessage("\n" + ex.StackTrace);
}
}

//Most of this is witn Tony's help
[DllImport("acdb17.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern ErrorStatus acdbGetObjectId(out ObjectId id, ref long ename);

[DllImport("acad.exe", EntryPoint = "?acedNEntSelPEx@@YAHPB_WQAJQANHQAY03NPAPAUresbuf@@IPAH@Z",
CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
private static extern int acedNEntSelPEx(string prompt,
out long adsname,
out Point3d picked,
int pickflag,
out Matrix3d transform,
out IntPtr resbuf,
uint transSpaceFlag,
out int gsMarker);

public static ObjectId acedNEntSelPExTest()
{
Point3d picked;
Matrix3d xform;
ObjectId objectId = ObjectId.Null;
long adsname = 0L;
IntPtr resbuf = IntPtr.Zero;
int gsmarker = 0;
if (acedNEntSelPEx("Pick something:",
out adsname,
out picked,
0,
out xform,
out resbuf,
0,
out gsmarker) == 5100)
{
using ((ResultBuffer)DisposableWrapper.Create
(typeof(ResultBuffer), resbuf, true))
{
acdbGetObjectId(out objectId, ref adsname);
}
}
return objectId;
}

artisteroi
2008-06-05, 12:24 PM
wow. Seems pretty complicated. I was hoping it would be more along the lines of the way dynamic properties are changed.

I wish it was like:
entity.3dsolid.solidtype
boxtype.Position x = (set new position)
boxtype.Position y= (set new position)
boxtype.Position z = (set new position)
boxtype.length = (set new size)
boxtype.width = (set new size)
boxtype.height = (set new size)
update
trans.commit

thats what I was hoping. But as always I find that there is nothing automatic about automation. We need to invent an developer language that is at least as easy to use as the working enviroment. Maybe its just me but sometimes it seems this stuff is complicated for no more reason than keeping other people from learning it. I guess that allows the real programmers to keep the compitition down for these types of jobs.
Sad really. Programming could be used for the betterment of man, but instead it is horded like all the other inventions that have been brought forth by man only to be corrupted by the darkness in our hearts....
hmmmm... I think I need to take my medicine. I'll be quite now

dmarcotte4
2008-06-05, 03:17 PM
Unfortunately, it’s not easy. It might be easier to replace the solid, than modify an existing one.