Author Topic: Programmatically change constraints?  (Read 2831 times)

0 Members and 1 Guest are viewing this topic.

sonny3g

  • Newt
  • Posts: 27
Programmatically change constraints?
« on: August 22, 2018, 08:22:40 AM »
I have posted before about this issue.  I have several hundred blocks that combine dynamic properties and constraints.  These blocks are supports that have to be able to adjust to custom heights and rotate a mounting head as needed.  Initially, the block inserts where the head mounts to a conveyor and the user drags a grip at the bottom of the support to the floor, then rotates the head with a grip if required.  Not all support heads need to be rotated.

The problem has been that using both constraints and dynamic properties cause copies of the support to make changes to all instances of that block when the user makes a change to any one of them.  If I restrict my block to just one constraint and as many dynamic properties as needed (the simplest block has at least two dynamic properties and the most complex has nearly 70) the problem goes away.  If I restrict the number of dynamic properties to one (rotate the support head) and use constraints in the place of the remaining dynamic properties, the block works correctly manually.

My program is trying to have the user pick the insertion point on a conveyor, a point at floor level, calculate the height and select the correct support, insert the block at the insertion point on the conveyor and stretch the bottom of the support down to the floor.  This works when I use dynamic properties for the length of the support.  But, the blocks require more than one constraint to maintain placement and positioning when the head is rotated.

So, I have to use more than one constraint to be able to accurately use these blocks.  Is there a way to  programmatically apply the same action of stretching the support to the floor on a constraint property as I am able to do when it is a dynamic property?

I am attaching two blocks, one with all dynamic and constraint properties and one with only one dynamic property and all required constraints.

I am working with AutoCAD 2016 using LISP to insert and change the blocks properties but I am also in the process of trying to figure out how to do this with C#.

Any help is appreciated.

sonny3g

  • Newt
  • Posts: 27
Re: Programmatically change constraints?
« Reply #1 on: August 23, 2018, 09:26:07 AM »
Does anyone know if this is even possible?

Atook

  • Swamp Rat
  • Posts: 1029
  • AKA Tim
Re: Programmatically change constraints?
« Reply #2 on: August 23, 2018, 12:59:55 PM »
Hey Sonny3G, not sure if it's possible, by the time I read a quarter of your question/description my mind wandered off to something else.

If you've got a LISP solution working, why port it to C#?

sonny3g

  • Newt
  • Posts: 27
Re: Programmatically change constraints?
« Reply #3 on: August 23, 2018, 01:09:29 PM »
Thanks Atook.
 
I know, description is overly long, but important. 

The LISP is not 100% and we are trying to make the user interface match the work being done on other corporate AutoCAD programs we developing.  It also the forerunner for some much more complicated programs we want to develop for our business partners and systems engineering department. 

I also wanted to try to teach myself C# programming on something that would seem to be simple at first glance.

Atook

  • Swamp Rat
  • Posts: 1029
  • AKA Tim
Re: Programmatically change constraints?
« Reply #4 on: August 23, 2018, 05:15:42 PM »
I've never worked with constraints, so I'm not sure about how to solve your problem.

A little digging around in the object browser shows the GeomtricConstraint class in AutoCAD.DatabaseServices.

I also found this link that talks about creating parametric and geometric constraints with .NET.

I have my doubts that it'd make a good starter .NET project, but it might. Like I said, I haven't worked with them before.

Dialog interfaces on .NET are easier I think, but in my experience, LISP is just as, if not more powerful than .NET overall.

« Last Edit: August 24, 2018, 01:53:48 PM by Atook »

sonny3g

  • Newt
  • Posts: 27
Re: Programmatically change constraints?
« Reply #5 on: August 24, 2018, 06:14:32 AM »
Really appreciate your feedback Atook. 

You may well be right about LISP vs .NET.  The powers that be here want what they want and so that is how it goes.  Next week it will be something else, but in the meantime, just keep digging the hole deeper.

Thanks for the link, I am going to spend some quality time checking it out.

Bryco

  • Water Moccasin
  • Posts: 1883
Re: Programmatically change constraints?
« Reply #6 on: August 26, 2018, 11:53:26 AM »
If the rotating top part is a separate block-you wont need any constraints.
So the user would pick the insertion point, then a point for the rotation or enter for 0, then click a point on the baseline.
Now you can use vectors to work out where the insertionpt will be (the axle point) and tell the second block to stretch to the ground.(I think you can set the distance)

sonny3g

  • Newt
  • Posts: 27
Re: Programmatically change constraints?
« Reply #7 on: August 27, 2018, 05:52:11 AM »
Bryco, I will have to give this some thought.  My first go round had me doing something similar by inserting all of the components of the support and making them into a block when it was done.  This was problematic for the users because of the need to tweek the support or because of changes later that would force them to create new supports instead of being able to modify the existing one.

Thanks for the response.