I've been working on a custom polyline object, and I've got it functioning!!!
Having said that, I plan to run its creation around picking a point for bounary selection.
(Other than trying to step through every vertecies) is there a technique I can thow the polyline data from a traceboundary result into my custom object? I've been trying to add the polyline from traceboundary to my object BEFORE it's added to the transaction by the way...I assume that's right, since I want to put it's data in my custom object then add my custom object to the transaction instead.
Thanks for any thought you might have,
Solved! Go to Solution.
II think there is no way to create a custom entitiy with .NET API in AutoCAD, please explain in more detail what your "custom polyline object" is, can you share the code?
First off, thanks as always for the response!
"II think there is no way to create a custom entitiy with .NET API in AutoCAD,"
True enough! I'm creating [have created, woot!] a custom derived AcDbPolyline in C++ , then using a manged wrapper to insert it into vb.net (ala the SimpleSquare or even PolySamp project in the ObjectARX SDK, though not using COM at this stage).
I'm actually very happy to upload the lot but I would need to clean it down - it has a lot of commented out code I plan to renenact later once base testing is doen.
Anyway it works a treat, but I'm not feeding it through a jig like simple square - I'm trying to use TraceBoundary in vb to get a polyline and pass the polyline data straight into my custom object (though as I slept last night it dawned on me I probably need to write a c++ routine to receive it...but since it's a superset, so to speak, of polyline all the data slots are there and I can't help wonderinig if there is a easy way to put the data in there.
Any how is the relavent code calling the object in vb - again if you want to see the whole thing let me know, i'll clean it up for upload.
Dim vb_LotObject As mgLotObject
'initalize the managed class
vb_LotObject = NewmgLotObject()
If vb_LotObject Is Nothing Then
Throw New ApplicationException("Could not create LOT")
Catch ex As Exception
MsgBox("Error during ADDSQ Command: " + ex.Message)
vb_LotObject.Normal = normal
'code polulating some dummy date etc
So, short of writing a routine to receive in my custom object, is there some cheeky way i can try
to cast /throw /heck, beg my polyine caught from :
resultTraceBoundary = ed.TraceBoundary(origin, False)
If resultTraceBoundary.Count > 0 Then
Dim ent As Entity = CType(resultTraceBoundary.Item(0), Entity)
into the mgLotObject above? I've tried a few ways of casting the polyline in or vice verca, but I'm totally guessing what AutoCAD will put up with here
I never did find a manged -> un-manged direct solution, but if anyone else is ever in this boat, here was my solution:
I created a c++ function inside my custom object called ConstructPoly - I pass it the ObjectID of the polyline I've created though TraceBoundary through the managed wrapper like so:
And then here is the actual unmanaged function that recieves it:
//make sure objectID not null
returnAcad::eNullObjectId;//<-if is drop out
//declare an entity
acutPrintf(_T("\nEntering Vertex Constructor: ObjectID = %d"),value);
//open entity for read
returnAcad::eNotOpenForRead;//<-drop out if fail
//confirm entity is open for read
returnAcad::eNullEntityPointer;//<- it isn't drop out
//its all good, check type
acutPrintf(_T("\nPassed Test, Entity IS a AcDbPolyline"));
// Use a for loop to get each vertex, one by one
acutPrintf(_T("\nFailed Test, Entity is NOT an AcDbPolyline"));
and then you can do this:
in vb.net and it creates the drived polyline object and deletes the polyline handed it.
Hope that helps someone
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.