AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Query with propertyalteration in .NET

1 REPLY 1
Reply
Message 1 of 2
fieldguy
530 Views, 1 Reply

Query with propertyalteration in .NET

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).

1 REPLY 1
Message 2 of 2
fieldguy
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!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost