User input with GetEntity

User input with GetEntity

a0503809662
Contributor Contributor
3,349 Views
17 Replies
Message 1 of 18

User input with GetEntity

a0503809662
Contributor
Contributor

Hi

I have many blockreferences in a drawing. this block has a  tag number .

How can I decide between two options on the same time: to select an object from the drawing or insert a number that represents the object.

I try the methog Getinput but these function return a value for the kryword number not the number that i insert it.

 

Thanks in advance.

0 Likes
Accepted solutions (1)
3,350 Views
17 Replies
Replies (17)
Message 2 of 18

seabrahenrique
Advocate
Advocate
Accepted solution

Hello!


What is the object type of your TAG? Is an attribute in your block?

0 Likes
Message 3 of 18

a0503809662
Contributor
Contributor

Hello !

 

the object tybe is an attribute in the blockreference. 

this is my code:

 

On Error Resume Next
ThisDrawing.Utility.InitializeUserInput 128, "Name"

ThisDrawing.Utility.GetEntity ent, StPnt, "Pick Point [Name]: "

str = ThisDrawing.Utility.GetInput

 

the str variable dont take the string number that i insert in the keyboard whan calling getEntity.

can you helb me ?

 

Thanks

 

0 Likes
Message 4 of 18

Ed__Jobe
Mentor
Mentor

Its not clear what you are trying to do. Can you explain each step and option?

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 5 of 18

a0503809662
Contributor
Contributor
HERE IS MY CODE:
On Error Resume Next
DIM ENT AS ACADBLOCKREFERENCE
DIM STR AS STRING
ThisDrawing.Utility.InitializeUserInput 128, "Name"
ThisDrawing.Utility.GetEntity ent, STR, "Pick Point [NAME]: "
If STR Then STR= ent.InsertionPoint
STR=ThisDrawing.Utility.GetInput

STR DONT RETURN THE VALUE FOR USER INPUT . HOW I COULD RETURN THE VALUE FOR STR OR PICK AN ENTITY?

THANKS,
0 Likes
Message 6 of 18

Ed__Jobe
Mentor
Mentor

That code is wrong and doesn't have enough information to describe what you want to do. Please describe in English what you want, the steps that a user should take. Then we can provide you the code.

 

By the way, GetEntity cannot get a string. It's designed to only get an Entity.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 7 of 18

a0503809662
Contributor
Contributor
I have a lot of blocks in the drawing that each block has a name inside that represents that block.

I want the user to select the block from the screen or enter a number to select the block through that name.

Thank you,
0 Likes
Message 8 of 18

a0503809662
Contributor
Contributor
Hello henriqueseabra

THE OBJECT TYPE IS A N ATTRIBUTE REFERENCE. AND ITIS INSIDE THE BLOCK.
0 Likes
Message 9 of 18

seabrahenrique
Advocate
Advocate

I don't know exactly what u need... but... to acess de atributes on a block reference u can use this:

 

Sub AtributesOnBlock()

Dim BlockRef As AcadBlockReference, Atts As Variant

ThisDrawing.Utility.GetEntity BlockRef, inspt, "Select a block..."

Atts = BlockRef.GetAttributes

For i = 0 To UBound(Atts)
    Debug.Print Atts(i).TextString
Next i

End Sub

 

If u can explain better your case, we can help 🙂

0 Likes
Message 10 of 18

Ed__Jobe
Mentor
Mentor

This should get you started.

Sub WorkWithBlock()
    Dim kwordlist As String
    kworkdlist = "Pick Name"
    Dim Response As String
    Dim MySS As AcadSelectionSet
    
    ThisDrawing.Utility.InitializeUserInput 38, kwordlist
    Response = ThisDrawing.Utility.GetKeyword("\nChoose whether to select block by Picking on-screen or entering its Name. [Pick/Name] :  <Pick>")
    Select Case Response
    Case Is = "Pick"
        Set MySS = GetSS_BlockFilter
    Case Is = "Name"
        Set MySS = GetSS_BlockAtt
    End Select
    
    'Do something with MySS
    
End Sub


Public Function GetSS_BlockFilter() As AcadSelectionSet
    'creates an ss of Blocks only
    Dim s1 As AcadSelectionSet      'for pfss
    Dim s2 As AcadSelectionSet      'for filtered ss
    
    Dim intFtyp(0) As Integer                       ' setup for the filter
    Dim varFval(0) As Variant
    Dim varFilter1, varFilter2 As Variant
    intFtyp(0) = 0: varFval(0) = "INSERT"           ' get only blocks
    varFilter1 = intFtyp: varFilter2 = varFval
    Set s2 = AddSelectionSet("ssBlockFilter")              ' create or get the set
    s2.Clear                                        ' clear the set
    s2.SelectOnScreen varFilter1, varFilter2        ' do it

    s2.Highlight True
    s2.Update
    Set GetSS_BlockFilter = s2

End Function

Public Function GetSS_BlockAtt(AttName As String) As AcadSelectionSet
    'creates a ss of blocks with the name supplied in the argument
    Dim s2 As AcadSelectionSet
    
    Set s2 = AddSelectionSet("ssBlocks")                ' create ss with a name
    s2.Clear                                        ' clear the set
    Dim intFtyp(0) As Integer                       ' setup for the filter
    Dim varFval(0) As Variant
    Dim varFilter1, varFilter2 As Variant
    intFtyp(0) = 0: varFval(0) = "INSERT"           ' get only blocks
    varFilter1 = intFtyp: varFilter2 = varFval
    s2.Select acSelectionSetAll, , , varFilter1, varFilter2        ' do it
    Dim oBlk As AcadBlockReference
    Dim oAtt As AcadAttributeReference
    For Each oBlk In s2
        Dim oAtts As Variant
        Dim cnt As Integer
        If oBlk.HasAttributes Then
            Set oAtts = oBlk.GetAttributes
            For i = 0 To UBound(oAtts)
                If oAtts(i).TextString = AttName Then
                    Dim ary(0) As Variant
                    Set ary(0) = oAtts(i)
                    s2.AddItems ary
                End If
            Next i
        End If
    Next oBlk
    Set GetSS_AttName = s2

End Function

Public Function AddSelectionSet(SetName As String) As AcadSelectionSet
' This routine does the error trapping neccessary for when you want to create a
' selectin set. It takes the proposed name and either adds it to the selectionsets
' collection or sets it.
    On Error Resume Next
    Set AddSelectionSet = ThisDrawing.SelectionSets.add(SetName)
    If Err.Number <> 0 Then
        Set AddSelectionSet = ThisDrawing.SelectionSets.Item(SetName)
        AddSelectionSet.Clear
    End If
End Function

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 11 of 18

a0503809662
Contributor
Contributor
Thank you so much for the work you have done, I know about the possibility of filtering the input.
But that's not what I wanted. I do not want to press P or N every time. I want to click a string asattribute name for example the number 10 or 25 or 70 ... or just select it from the screen.

I will attach the DWG file for the blocks I have in the drawing.
0 Likes
Message 12 of 18

a0503809662
Contributor
Contributor

here is a dwg for downloading.

 

@Ed__Jobe 

@seabrahenrique 

0 Likes
Message 13 of 18

Ed__Jobe
Mentor
Mentor

@a0503809662 wrote:
Thank you so much for the work you have done, I know about the possibility of filtering the input.
But that's not what I wanted. I do not want to press P or N every time. I want to click a string asattribute name for example the number 10 or 25 or 70 ... or just select it from the screen.

I will attach the DWG file for the blocks I have in the drawing.

That's the kind of description I asked for when I said describe in English what you want to do. I can't read your mind.

 

What is different about what you want to do from just clicking on an entity? "Just select it from the screen." How is this different from selecting a block attribute?

 

If you don't filter for a block, how will the program know that you didn't select a line or circle? A program follows specific instructions. It can't read your mind either.

 

Also, if you are having difficulty describing in English, use your native language and I'll use Google Translate.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 14 of 18

a0503809662
Contributor
Contributor

@Ed__Jobe @seabrahenrique 

Hi,

I upload pictures that show my problem.
I want to receive text input from the user During  GETENTITY function works.
The function LASTPROMPT does not allow me to receive the input of the text from the user.
What can I do to solve the problem?
Many thanks in advance
 

 

0 Likes
Message 15 of 18

Ed__Jobe
Mentor
Mentor

GetEntity can't do what you're asking (read the help topic). As the name implies, it gets an Entity, not a String. That's why I structured the command the way I did in my first post. You can only use the tools that your are given. With GetKeyword instead of GetEntity, you can get user input to help you make processing decisions.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 16 of 18

a0503809662
Contributor
Contributor

Is it possible to edit GETENTITY CLASS ?

I searched for a solution to the problem and I found that there is a  solution for my problem called GETXX class but I did not found this class.

Is it possible to build such as class Getxx Class?

 

Tthank in advance

0 Likes
Message 17 of 18

Ed__Jobe
Mentor
Mentor

No, it's not possible to rewrite the GetEntity method. GetXX is just short for all the Get methods, XX are variables. You substitute Entity..Point..Real..Integer, etc. They belong to ThisDrawing.Utility.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 18 of 18

a0503809662
Contributor
Contributor

But if you use the function ''LASTPROMPT'' YOU CAN RETURN ONLY NUMERIC INPUT. TRY TO USE IT , "LASTPROMPT" RETURN THE NUMERIC INPUT AND "ENTER" AND "ESC" WITH GETENTITY ..

IN MY CASE I WANT TO RETURN ALSO A STRING.

 

0 Likes