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

Dynamically change block scale while in JIG

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
a.kouchakzadeh
234 Views, 3 Replies

Dynamically change block scale while in JIG

Hello

Is it possible to have a prompt double options while in JIG and use its result to update a jigged block reference scale in real time?

 

this is the code that I have but the screen flickers:

 

public class JigBlockReference : EntityJig
    {
        protected Point3d dragPoint;
        protected BlockReference blockReference;
        private bool _firstLoop;
        public JigBlockReference(BlockReference br,bool firstLoop)
            : base(br)
        {
            this.blockReference = br;
            dragPoint = br.Position;
            _firstLoop = firstLoop;
        }

        protected override SamplerStatus Sampler(JigPrompts prompts)
        {
            var ops = new JigPromptStringOptions("Enter scale");
            var res = prompts.AcquireString(ops);
            if(double.TryParse(res.StringResult, out double scale))
            {
                blockReference.ScaleFactors = new Scale3d(scale);
            }

            var options = new JigPromptPointOptions("\nSpecify destination point");
            options.UserInputControls = (UserInputControls.GovernedByOrthoMode);
            var result = prompts.AcquirePoint(options);
            if (dragPoint.IsEqualTo(result.Value))
                return SamplerStatus.NoChange;
            else
                dragPoint = result.Value;
            return SamplerStatus.OK;
        }

        protected override bool Update()
        {
            blockReference.Position = dragPoint;
            return true;
        }
    }

 

var blockRef = new BlockReference(Point3d.Origin, blockDef);
                    blockRef.TransformBy(ed.CurrentUserCoordinateSystem);
                    var jig = new JigBlockReference(blockRef, firstLoop);
                    var jigResult = ed.Drag(jig);
                    if (jigResult.Status == PromptStatus.OK)
                    {
                        var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                        curSpace.AppendEntity(blockRef);
                        tr.AddNewlyCreatedDBObject(blockRef, true);
                    }

 

"Enter Scale" wont show unless I press escape.

3 REPLIES 3
Message 2 of 4

You can use option keywords with a jig.

 

See this blog post

Message 3 of 4

you can also use a counter, I think the ARX ellipse  jig sample does this

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
Message 4 of 4

I also found this post as well. but Kean's post was a nice one.

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

Post to forums  

Forma Design Contest


AutoCAD Beta