AutoCAD Map 3D Developer

Valued Mentor
Posts: 358
Registered: ‎03-31-2005
Message 1 of 2 (267 Views)

Query with propertyalteration in .NET

267 Views, 1 Replies
04-25-2012 10:05 AM

Can someone provide an example or link on how to create a propertyalteration in a query using C# or VB?


I have found the ObjectARX example >>here<< but my C skills are very limited.  If someone could tell me how to add that to >>this<< I will be forever in your debt. 


I am to the point where I can query text objects from a layer, but I need to know how to put them on to a different layer ("TEST" for example).

Valued Mentor
Posts: 358
Registered: ‎03-31-2005
Message 2 of 2 (263 Views)

Re: Query with propertyalteration in .NET

04-25-2012 10:43 AM in reply to: fieldguy

I should have waited.  I found the answer in the Map SDK examples in SessionSampleCommand.cs.


<CommandMethod("q8")> _
    Sub q_8()
        Dim prjModel As ProjectModel = HostMapApplicationServices.Application.ActiveProject
        prjModel.Options.MarkObjectsForEditingWithoutPrompting = True
        Dim dwgset As DrawingSet = prjModel.DrawingSet
        dwgset.AttachDrawing("some dwg file")
        Dim qryModel As QueryModel = prjModel.CurQuery
        qryModel.Mode = QueryType.QueryDraw
        Dim qryRoot As QueryBranch = QueryBranch.Create()
        Dim loccond As LocationCondition = New LocationCondition()
        loccond.LocationType = LocationType.LocationInside
        Dim polypts As New Point3dCollection()
        polypts.Add(New Point3d(p1x,p1y,p1z))
        polypts.Add(New Point3d(p2x,p2y,p2z))
        polypts.Add(New Point3d(p3x,p3y,p3z))
        polypts.Add(New Point3d(p4x,p4y,p4z))
        Dim qpoly As New PolygonBoundary(polypts)
        loccond.Boundary = qpoly
        Dim qblocation As QueryBranch = QueryBranch.Create()
        Dim propcond As PropertyCondition = New PropertyCondition()
        propcond.JoinOperator = JoinOperator.OperatorAnd
        propcond.PropertyType = PropertyType.Layer
        propcond.ConditionOperator = ConditionOperator.ConditionEqual
        Dim thelayers As String = "CSV source layer names"
        propcond.Value = thelayers
        Dim qbproperty As QueryBranch = QueryBranch.Create()
        Dim prop2 As PropertyCondition = New PropertyCondition()
        prop2.JoinOperator = JoinOperator.OperatorAnd
        prop2.PropertyType = PropertyType.EntityType
        prop2.ConditionOperator = ConditionOperator.ConditionEqual
        prop2.Value = "TEXT"
        Dim qbprop2 As QueryBranch = QueryBranch.Create()
        'alter prop
        Dim propdef As PropertyAlterationDefinition = qryModel.PropertyAlteration
        Dim propalterlayer As PropertyAlteration = Nothing
        propalterlayer = propdef.AddAlteration(AlterationType.AlterationLayer)
        propalterlayer.Expression = "TEST"
        Dim propalterstyle As PropertyAlteration = Nothing
        propalterstyle = propdef.AddAlteration(AlterationType.AlterationStyle)
        propalterstyle.Expression = "STANDARD"
        Dim queriedobjids As ObjectIdCollection = qryModel.Execute(dwgset)
End Sub

 Thanks for >>this<< djonio!

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community