New inserted block doesn't seems to have snap point

New inserted block doesn't seems to have snap point

Anonymous
Not applicable
586 Views
6 Replies
Message 1 of 7

New inserted block doesn't seems to have snap point

Anonymous
Not applicable

Hi Guys,

I use the following code insert block

            Using myTrans As Transaction = db.TransactionManager.StartTransaction

                Dim myBT As BlockTable = db.BlockTableId.GetObject(OpenMode.ForRead)
                Dim myBTR As BlockTableRecord = myBT(BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite)

                'Insert the Block
                Dim myBlockDef As BlockTableRecord = _
                    myBT(Me.BlockName).GetObject(OpenMode.ForRead)
                myBlockRef = New DatabaseServices.BlockReference(InsertPoint, myBT(BlockName))
                myBlockRef.ScaleFactors = New Geometry.Scale3d(1, 1, 0)
                myBlockRef.Rotation = FixtureRotation

                myBTR.AppendEntity(myBlockRef)
                myTrans.AddNewlyCreatedDBObject(myBlockRef, True)
                myTrans.Commit()
            End Using

 After coe excuted new block has been insert. Then I found regardless I turn on/off onsap there is no sappoint on those newly added blocks.

 

It should looks like

my new inserted block

What did I do wrong? Any ideas ?

 

Thanks very much

0 Likes
587 Views
6 Replies
Replies (6)
Message 2 of 7

arcticad
Advisor
Advisor

Just looking at your code the Z scale is at 0.

---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 3 of 7

Anonymous
Not applicable

Thanks for reply. I changed zscale to 1.0 , still no grip pointSmiley Sad

0 Likes
Message 4 of 7

Anonymous
Not applicable

After more investigation. I found new inserted block display grip point, If I use "Line" command.

However once I run my own draw line function. the grip point turned off.

Even worse,after I run my own draw line code, back to AutoCAD "Line" command, those grip point never turn back

Here is my draw line code.

 

    Private Function DrawAlignLine(ByRef StartPoint As Point3d, ByRef EndPoint As Point3d, Optional ByRef strError As String = "") As Boolean
        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim acCurDb As Database = acDoc.Database
        Dim pPtRes As PromptPointResult
        Dim pPtOpts As PromptPointOptions = New PromptPointOptions("")
        Try
            '' Prompt for the start point
            pPtOpts.Message = vbLf & "Enter the start point of the line: "
            pPtRes = acDoc.Editor.GetPoint(pPtOpts)
            If pPtRes.Status <> PromptStatus.OK Then
                Return True
            End If
            StartPoint = pPtRes.Value
            pPtOpts.AllowNone = True
            '' Prompt for the end point
            pPtOpts.Message = vbLf & "Please enter the next point of the line: "
            pPtOpts.UseBasePoint = True
            pPtOpts.BasePoint = StartPoint
            Dim DrawComplete As Boolean = False
            Do
                pPtRes = acDoc.Editor.GetPoint(pPtOpts)
                If pPtRes.Status <> PromptStatus.OK Then
                    StartPoint = Nothing
                    Return True
                End If
                '--Start point different to end point 
                If pPtRes.Value.IsEqualTo(StartPoint) = False Then
                    DrawComplete = True
                End If
            Loop Until DrawComplete = True
            EndPoint = pPtRes.Value
            Return True
        Catch sysex As SystemException
            strError = sysex.Message
            StorePlanLogError(sysex, sysex.Message, STR_MODULE_NAME & ".DrawAlignLine")
        Catch ex As Exception
            strError = ex.Message
            StorePlanLogError(ex, ex.Message, STR_MODULE_NAME & ".DrawAlignLine")
        End Try
    End Function

 Thanks

0 Likes
Message 5 of 7

Anonymous
Not applicable

More investigation done, it is either a silly question or very strange one

 

Replication Step

1. Insert block(use the code I provided above)
2. type line command-->user can see new block grip point
3. Draw line use my code(code provided above)-->User cannot see grip point
4. Click Esc once, then type regen command, then type line command--> user can see grip point again

 

What on earth happened to my code

 

Please help

0 Likes
Message 6 of 7

kerry_w_brown
Advisor
Advisor

 

By my reading of your code the DrawAlignLine does not draw a line, it just gets the start and end points.

 

Possibly related :

Why are you returning true if either of the point selections fail ?

 

I'd need to see a compilable Project to guess at the cause of your problem.

 

Regards

 

 


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 7 of 7

Anonymous
Not applicable

Thanks for your reply.

 

The code is not draw line, it is finding 2 point. while doing that I can't see new block's grips point however I can see others.

 

That's the strange part.

 

Any idea?

0 Likes