I am seeing the error (Value does not fall within the expected range.) being thrown whenever the new ObjectIdCollection contains a Featureline (Auto Corridor Featurelines work though) and I try SubassemblyTargetInfo.TargetIds = newObjectIdCollection. Anyone else come across this error?
Sample code to play with:
[CommandMethod( "TargetExample" )] public void RunCommand() { var id = SelectTarget(); var db = Application.DocumentManager.MdiActiveDocument.Database; var ed = Application.DocumentManager.MdiActiveDocument.Editor; var civilDoc = CivilApplication.ActiveDocument; using ( var trans = db.TransactionManager.StartTransaction() ) { try { var alignmentId = civilDoc.GetAlignmentIds()[0]; var alignment = trans.GetObject( alignmentId, OpenMode.ForRead ) as Alignment; var profileId = alignment.GetProfileIds()[0]; var assemblyId = civilDoc.AssemblyCollection[0]; var newCorridorId = civilDoc.CorridorCollection.Add( "Proposed Corridor", "Proposed Baseline", alignmentId, profileId, "Proposed BaselineRegion", assemblyId ); var corridor = trans.GetObject( newCorridorId, OpenMode.ForWrite ) as Corridor; var subtargetinfocoll = corridor.GetTargets(); for ( int i = 0; i < subtargetinfocoll.Count; i++ ) { var subassemblytargetinfo = subtargetinfocoll[i]; if ( subassemblytargetinfo.TargetType == SubassemblyLogicalNameType.Offset ) { var ids = new ObjectIdCollection(); ids.Add( id ); subassemblytargetinfo.TargetIds = ids; } } corridor.SetTargets( subtargetinfocoll ); corridor.Rebuild(); trans.Commit(); } catch ( Exception ex ) { ed.WriteMessage( "\nError: {0}\nTarget type: {1}", ex.Message, id.ObjectClass.DxfName ); } } } private ObjectId SelectTarget() { var result = ObjectId.Null; var peo = new PromptEntityOptions( "\nSelect the corridor offset target" ); var per = Application.DocumentManager.MdiActiveDocument.Editor.GetEntity( peo ); switch ( per.Status ) { case PromptStatus.OK: { result = per.ObjectId; } break; default: break; } return result; }
Hi,
I think it pretty much depends on the drawing and which element do you select as target. Do you complete your operation with UI? If you can do it with UI but has problem with API, would you please send us a sample drawing and direct me which element I should select as corridor offset target to reproduce your problem?
You can use the attached drawing as a test. The original code provided by the Dev blog I based the sample on just said to use any of the help sample drawings. This drawing is based on Corridor 1a.dwg.
When you run the test command, all of the common target types work fine except the standard Featureline (as specified in the original post). Attaching a featureline target through the UI works fine.
I attached some new code to work a bit nicer with the example drawing.
Thank you for the sample, I am contacting with engineering team for this issue, I will get back to you when I get a response.
Thanks for looking into this Daniel.
Is there such a thing as a AeccDbAutoFeatureLine? I don't see a class for it and I haven't come across one in a drawing.
The API documentation simply calls for a FeatureLine:
When TargetType is Offset, the type of ObjectId should be Alignment, FeatureLine, SurveyFigure, Polyline, Polyline2d or Polyline3d.
Thank you for the feedback, I've logged a change request to support AeccDbFeatureLine for API to engineering team.
I am in the same needs.
It is November 2016........ (2 YEARS LATER) and there is no news in C3D 2017 SP1.1 API ¿? WTF...
Hi all,
I am facing similar problem with API.
It does not allow me to set feature line as offset target.
Is there any update on this issue?
Please suggest me if there is any other solution for this.
Thanking you,
Rahul.