AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

Reply
Valued Mentor
fieldguy
Posts: 368
Registered: ‎03-31-2005
Message 1 of 2 (271 Views)

Query with propertyalteration in .NET

271 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
fieldguy
Posts: 368
Registered: ‎03-31-2005
Message 2 of 2 (267 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
        qryModel.Clear()
        Dim qryRoot As QueryBranch = QueryBranch.Create()
        'location
        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()
        qblocation.AppendOperand(loccond)
        qryRoot.AppendOperand(qblocation)
        'properties
        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()
        qbproperty.AppendOperand(propcond)
        qryRoot.AppendOperand(qbproperty)
        '
        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()
        qbprop2.AppendOperand(prop2)
        qryRoot.AppendOperand(qbprop2)
        '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"
        qryModel.EnablePropertyAlteration(True)
        qryModel.Define(qryRoot)
        Dim queriedobjids As ObjectIdCollection = qryModel.Execute(dwgset)
End Sub

 Thanks for >>this<< djonio!

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.