.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Mono condition to multy condition.

27 REPLIES 27
Reply
Message 1 of 28
Anonymous
1072 Views, 27 Replies

Mono condition to multy condition.

HI, all.
The code below is the example of selecting text, if selected appropriately, Msgbox show the information of height of the text. Additionally to this, I wish to add one more condition,
entity is text and the layername is " LEVEL".
Plz, help me. Good day.

_
Public Sub GetEntity()
Dim currentEditor As AcEd.Editor = AcAs.Application.DocumentManager.MdiActiveDocument.Editor
Dim entitySelectionOpts As AcEd.PromptEntityOptions = New AcEd.PromptEntityOptions("" & Microsoft.VisualBasic.Chr(10) & "Select Text: ")
entitySelectionOpts.SetRejectMessage("" & Microsoft.VisualBasic.Chr(10) & "Only Textes may be selected.")
entitySelectionOpts.AddAllowedClass(GetType(AcDb.DBText), True)
Dim entitySelectionResult As AcEd.PromptEntityResult = currentEditor.GetEntity(entitySelectionOpts)
If entitySelectionResult.Status = AcEd.PromptStatus.OK Then
DisplayTextHeight(entitySelectionResult.ObjectId)
End If
End Sub

Private Sub DisplayTextHeight(ByVal textId As AcDb.ObjectId)
Dim currentEditor As AcEd.Editor = AcAs.Application.DocumentManager.MdiActiveDocument.Editor
' Using
Dim trans As AcDb.Transaction = currentEditor.Document.TransactionManager.StartTransaction
Try
Dim selectedText As AcDb.DBText = CType(trans.GetObject(textId, AcDb.OpenMode.ForRead), AcDb.DBText)
AcAs.Application.ShowAlertDialog("Text: " + selectedText.Height.ToString)
Finally
CType(trans, IDisposable).Dispose()
End Try
End Sub
27 REPLIES 27
Message 2 of 28
Anonymous
in reply to: Anonymous

[code]

'Build a filter for just "TEXT" on "YourLayer"

Dim filList(1) As TypedValue

filList(0) = New TypedValue(DxfCode.Start, "TEXT")

filList(1) = New TypedValue(DxfCode.LayerName, "YourLayer")

Dim filter As SelectionFilter = New SelectionFilter(filList)

Dim res As PromptSelectionResult = ed.GetSelection(Opts, filter)

[/code]

wrote in message news:5427977@discussion.autodesk.com...
HI, all.
The code below is the example of selecting text, if selected appropriately,
Msgbox show the information of height of the text. Additionally to this, I
wish to add one more condition,
entity is text and the layername is " LEVEL".
Plz, help me. Good day.

_
Public Sub GetEntity()
Dim currentEditor As AcEd.Editor =
AcAs.Application.DocumentManager.MdiActiveDocument.Editor
Dim entitySelectionOpts As AcEd.PromptEntityOptions = New
AcEd.PromptEntityOptions("" & Microsoft.VisualBasic.Chr(10) & "Select Text:
")
entitySelectionOpts.SetRejectMessage("" &
Microsoft.VisualBasic.Chr(10) & "Only Textes may be selected.")
entitySelectionOpts.AddAllowedClass(GetType(AcDb.DBText), True)
Dim entitySelectionResult As AcEd.PromptEntityResult =
currentEditor.GetEntity(entitySelectionOpts)
If entitySelectionResult.Status = AcEd.PromptStatus.OK Then
DisplayTextHeight(entitySelectionResult.ObjectId)
End If
End Sub

Private Sub DisplayTextHeight(ByVal textId As AcDb.ObjectId)
Dim currentEditor As AcEd.Editor =
AcAs.Application.DocumentManager.MdiActiveDocument.Editor
' Using
Dim trans As AcDb.Transaction =
currentEditor.Document.TransactionManager.StartTransaction
Try
Dim selectedText As AcDb.DBText = CType(trans.GetObject(textId,
AcDb.OpenMode.ForRead), AcDb.DBText)
AcAs.Application.ShowAlertDialog("Text: " +
selectedText.Height.ToString)
Finally
CType(trans, IDisposable).Dispose()
End Try
End Sub
Message 3 of 28
Anonymous
in reply to: Anonymous

Thank you, Paul.
Good Day!
Message 4 of 28
Anonymous
in reply to: Anonymous

Wait, One more question is.
Three or more condition also possible?
Thank you in advance.
Message 5 of 28
Anonymous
in reply to: Anonymous

For example,
line and layer1 or
text and layer2 or
text and layer3

is this possible?
Message 6 of 28
Anonymous
in reply to: Anonymous

filList(0) = New TypedValue(DxfCode.Start, "TEXT,LINE")
filList(1) = New TypedValue(DxfCode.LayerName, "YourLayer,YourOtherLayer")

wrote in message news:5428336@discussion.autodesk.com...
For example,
line and layer1 or
text and layer2 or
text and layer3

is this possible?
Message 7 of 28
Anonymous
in reply to: Anonymous

Thank you so much, Paul.
Have a nice day!
Message 8 of 28
Anonymous
in reply to: Anonymous

You're welcome. Enjoy your day too...:)

wrote in message news:5428355@discussion.autodesk.com...
Thank you so much, Paul.
Have a nice day!
Message 9 of 28
Anonymous
in reply to: Anonymous

>line and layer1 or
>text and layer2 or
>text and layer3

I should have read this closer. You will need to build a conditional filter
as such
to match above example.

Dim filterlist(9) As TypedValue

filterlist(0) = New TypedValue(-4, "
filterlist(1) = New TypedValue(-4, "
filterlist(2) = New TypedValue(0, "LINE")

filterlist(3) = New TypedValue(8, "layer1")

filterlist(4) = New TypedValue(-4, "and>")

filterlist(5) = New TypedValue(-4, "
filterlist(6) = New TypedValue(0, "TEXT")

filterlist(7) = New TypedValue(8, "layer2,layer3")

filterlist(8) = New TypedValue(-4, "and>")

filterlist(9) = New TypedValue(-4, "or>")



wrote in message news:5428336@discussion.autodesk.com...
For example,
line and layer1 or
text and layer2 or
text and layer3

is this possible?
Message 10 of 28
Anonymous
in reply to: Anonymous

Very Very Good.
That's it what I want.
Thank you again, Paul.
Message 11 of 28
Anonymous
in reply to: Anonymous

Huuu.., It doesn't work.
How shall I fix it?

Dim fl(3) As TypedValue
fl(0) = New TypedValue(-4, " fl(1) = {new typedvalue(-4,"")}
fl(2) = {new typedvalue(-4,"")}
fl(3) = New TypedValue(-4, "OR>")
Message 12 of 28
Anonymous
in reply to: Anonymous

I attached text file included all text.
Above is not complete sentence.
Help me again. Thanks in advance.
Message 13 of 28
Anonymous
in reply to: Anonymous

")}
I don't know that you can string them together like this...
Have you tried like I posted.

wrote in message news:5428370@discussion.autodesk.com...
Huuu.., It doesn't work.
How shall I fix it?

Dim fl(3) As TypedValue
fl(0) = New TypedValue(-4, " fl(1) = {new typedvalue(-4," New TypedValue(8, "T1"),new typedvalue(-4,"AND>")}
fl(2) = {new typedvalue(-4," New TypedValue(8, "T2"),new typedvalue(-4,"AND>")}
fl(3) = New TypedValue(-4, "OR>")
Message 14 of 28
Anonymous
in reply to: Anonymous

Yes, I just have tested.
But, No error ,no reaction has made.
I attached file tested.
Message 15 of 28
Anonymous
in reply to: Anonymous

I don't know what you are doing. Why don't you have your
filter like I showed you?

Dim filterlist(9) As TypedValue
filterlist(0) = New TypedValue(-4, " filterlist(1) = New TypedValue(-4, " filterlist(2) = New TypedValue(0, "LINE")
filterlist(3) = New TypedValue(8, "layer1")
filterlist(4) = New TypedValue(-4, "and>")
filterlist(5) = New TypedValue(-4, " filterlist(6) = New TypedValue(0, "TEXT")
filterlist(7) = New TypedValue(8, "layer2,layer3")
filterlist(8) = New TypedValue(-4, "and>")
filterlist(9) = New TypedValue(-4, "or>")

wrote in message news:5428409@discussion.autodesk.com...
Yes, I just have tested.
But, No error ,no reaction has made.
I attached file tested.
Message 16 of 28
Anonymous
in reply to: Anonymous

I just understood what you are to write.

filterlist(0) = New TypedValue(-4, " filterlist(1) = New TypedValue(-4, " filterlist(2) = New TypedValue(0, "CIRCLE")
filterlist(3) = New TypedValue(8, "Layer1")
filterlist(4) = New TypedValue(-4, "AND>")
filterlist(5) = New TypedValue(-4, " filterlist(6) = New TypedValue(0, "LINE")
filterlist(7) = New TypedValue(8, "Layer2")
filterlist(8) = New TypedValue(-4, "AND>")
filterlist(9) = New TypedValue(-4, "OR>")

Right? But, This causes also error.
What should I do?
Message 17 of 28
Anonymous
in reply to: Anonymous

Shit! It was a http bug!
IT cannot show all the line that I wrote.
Message 18 of 28
Anonymous
in reply to: Anonymous

What version are you using. Filters only started working
in 07 I think. If this is the case, you will need to use
COM. Someone please correct me.

wrote in message news:5428601@discussion.autodesk.com...
I just understood what you are to write.

filterlist(0) = New TypedValue(-4, " filterlist(1) = New TypedValue(-4, " filterlist(2) = New TypedValue(0, "CIRCLE")
filterlist(3) = New TypedValue(8, "Layer1")
filterlist(4) = New TypedValue(-4, "AND>")
filterlist(5) = New TypedValue(-4, " filterlist(6) = New TypedValue(0, "LINE")
filterlist(7) = New TypedValue(8, "Layer2")
filterlist(8) = New TypedValue(-4, "AND>")
filterlist(9) = New TypedValue(-4, "OR>")

Right? But, This causes also error.
What should I do?
Message 19 of 28
Anonymous
in reply to: Anonymous

VS. 2005 and AutoCAD 2007
Message 20 of 28
cgay
in reply to: Anonymous

Maybe this will help:
[code]
Public Sub GetEntity()
Dim currentEditor As AcED.Editor = AcAS.Application.DocumentManager.MdiActiveDocument.Editor

'Setup Selection Options
Dim SelectionOpts As AcED.PromptSelectionOptions = New AcED.PromptSelectionOptions()
With SelectionOpts
SelectionOpts.MessageForAdding = ControlChars.NewLine & "Select Text Objects: "
SelectionOpts.MessageForRemoval = ControlChars.NewLine & "Only Text/MText Objects may be selected."
SelectionOpts.AllowDuplicates = False
End With

'Setup Selection Filter
Dim selfilQue As New Generic.Queue(Of AcadDS.TypedValue)
With selfilQue
.Enqueue(New Autodesk.AutoCAD.DatabaseServices.TypedValue(-4, "<AND"))
.Enqueue(New Autodesk.AutoCAD.DatabaseServices.TypedValue(8, "YourLayerName"))
.Enqueue(New Autodesk.AutoCAD.DatabaseServices.TypedValue(-4, "<OR"))
.Enqueue(New Autodesk.AutoCAD.DatabaseServices.TypedValue(0, "TEXT"))
.Enqueue(New Autodesk.AutoCAD.DatabaseServices.TypedValue(0, "MTEXT"))
.Enqueue(New Autodesk.AutoCAD.DatabaseServices.TypedValue(-4, "OR>"))
.Enqueue(New Autodesk.AutoCAD.DatabaseServices.TypedValue(-4, "AND>"))
End With
Dim selFil As New Autodesk.AutoCAD.EditorInput.SelectionFilter(selfilQue.ToArray)

'Query for the Objects
Dim SelectionResult As AcED.PromptSelectionResult = currentEditor.GetSelection(SelectionOpts, selFil)
If SelectionResult.Status = AcED.PromptStatus.OK Then
Using Doc As AcadAS.Document = AcadAS.Application.DocumentManager.MdiActiveDocument
Using trans As AcDB.Transaction = Doc.TransactionManager.StartTransaction
For Each selObj As AcED.SelectedObject In SelectionResult.Value
Using dbObj As AcDB.DBObject = trans.GetObject(selObj.ObjectId, AcDB.OpenMode.ForRead)
If TypeOf dbObj Is AcDB.DBText Then
Using selectedText As AcDB.DBText = DirectCast(dbObj, AcDB.DBText)
AcAS.Application.ShowAlertDialog(" Text: " & selectedText.Height.ToString)
End Using
ElseIf TypeOf dbObj Is AcDB.MText Then
Using selectedText As AcDB.MText = DirectCast(dbObj, AcDB.MText)
AcAS.Application.ShowAlertDialog("MText: " & selectedText.TextHeight.ToString)
End Using
End If
End Using
Next
trans.Commit()
End Using
End Using
End If
End Sub
[/code]

C

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost