trigger offset command

trigger offset command

Anonymous
Not applicable
1,760 Views
8 Replies
Message 1 of 9

trigger offset command

Anonymous
Not applicable

I want to trigger the offset command.

Then ask for a distance.

So i can change the distance with a scalefactor

And put it to the variable offsetdist ???

Then resume the offset command with that changed distance

 

Is this possible, and how?

 

0 Likes
1,761 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable

Yes, it's possible. Write a small program (macro) to do it. Start it out and post an example here when you need help with any specific problem(s).

0 Likes
Message 3 of 9

Anonymous
Not applicable

this is what i have

 

AddHandler Application.DocumentManager.MdiActiveDocument.CommandWillStart, New CommandEventHandler(AddressOf cmdWillStart)

 

 

    Public Sub cmdWillStart(ByVal o As Object, ByVal e As CommandEventArgs)

        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument

        Dim acCurDb As Database = acDoc.Database

        Dim acDocEd As Editor = acDoc.Editor

        Dim xafstand As Double

        If e.GlobalCommandName = "OFFSET" Then

 

            Dim pIntOpts As PromptDistanceOptions = New PromptDistanceOptions("")

            xafstand = Application.GetSystemVariable("offsetdist") * iSchaal / iHoofdschaal

            pIntOpts.Message = vbCrLf & "Geef afstand (" & xafstand & "): "

            pIntOpts.AllowNegative = False

            pIntOpts.AllowZero = False

            pIntOpts.AllowNone = False

            pIntOpts.UseDashedLine = True

 

            Dim pIntres As PromptDoubleResult = acDocEd.GetDistance(pIntOpts)

            MsgBox(Application.GetSystemVariable("offsetdist"))

            xafstand = pIntres.Value * iHoofdschaal / iSchaal

            Application.SetSystemVariable("offsetdist", xafstand)

            acDoc.SendStringToExecute(" ", True, False, False)

         End If

 

    End Sub

 

0 Likes
Message 4 of 9

Anonymous
Not applicable

OK... what problem are you having with this routine? I don't know what your variable names mean... and, of course, we have no way to know what value(s) (or even types) your variables contain.

 

 

Steve

 

0 Likes
Message 5 of 9

Norman_Yuan
Mentor
Mentor

Do you really want to change the behaviour of Acad built-in command "Offset" and force it on users? I would not.

 

With sufficiently available .NET API, it is fairly simple to do your own command that does custom "offset", which co-exists with Acad built-in "Offset" command, with various Ediotr.GetXXX() methods for collecting user input and Curve.GetOffsetCurves() for creating the offset entities.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 6 of 9

Anonymous
Not applicable

I can make a command to offset entities, but i don't no how to trigger wich side the offset should be.

Offset works with positive and negative value.

For me was in VBA the easiest way to change the offsetdist at the beginning of the offset command.

But this is more difficult in vb.net

 

0 Likes
Message 7 of 9

Anonymous
Not applicable
0 Likes
Message 8 of 9

Anonymous
Not applicable

Thanks Jeffrey.

I will try to convert it to vb.net, because that is what i can/need

 

0 Likes
Message 9 of 9

Anonymous
Not applicable

The offset is working, now i want a ask voor a side to offset

That is my little problem

  

 Public Sub customoffset()

        Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
        Dim acCurDb As Database = acDoc.Database
        Dim acDocEd As Editor = acDoc.Editor
        Dim prObjectOptions As PromptEntityOptions = New PromptEntityOptions("Selecteer een object : ")
        Dim pt As Object
        pt = acDocEd.GetEntity(prObjectOptions)
        If pt.Status <> PromptStatus.OK Then Exit Sub
        Dim pIntOpts As PromptIntegerOptions = New PromptIntegerOptions("")
        pIntOpts.Message = vbCrLf & "Geef afstand : "
        pIntOpts.AllowZero = False
        pIntOpts.AllowNegative = False
        pIntOpts.AllowNone = True
        Dim pIntRes As PromptIntegerResult = acDoc.Editor.GetInteger(pIntOpts)
        iOffset = Val(pIntRes.Value.ToString)
        Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
            Dim acBlkTbl As BlockTable
            acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
            Dim acBlkTblRec As BlockTableRecord
            acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
            Dim ent As Object = acTrans.GetObject(pt.objectid, OpenMode.ForRead)
            Dim acDbObjColl As DBObjectCollection = ent.GetOffsetCurves(iOffset)
            For Each acEnt As Entity In acDbObjColl
                acBlkTblRec.AppendEntity(acEnt)
                acTrans.AddNewlyCreatedDBObject(acEnt, True)
            Next
            acTrans.Commit()
        End Using


    End Sub

0 Likes