TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: xiaxiang on November 21, 2010, 10:40:05 PM

Title: Need help--About Dimension Driven
Post by: xiaxiang on November 21, 2010, 10:40:05 PM
I need a function to achieve changing length of entity when changging its Associated dim.
I have a routine but it dosen't work.
Thanks to all that have seen this topic.Any suggestion welcome
Code: [Select]
(defun c:cd(/ BLB EP ESPL N-EP N-SP NEW-T SD SD-DXF SEA SEB SP SS1 SS2 SS3)
  (setq SD (entsel "\n Select Dimension Driven :"))
  (if SD
    (PROGN
      (SETQ SD-DXF (ENTGET (CAR SD)))
      (WHILE (NOT (wcmatch (CDR (ASSOC 0 SD-DXF)) "*DIM*"))
 (setq SD (entsel "\n Select Dimension Driven :"))
 (SETQ SD-DXF (ENTGET (CAR SD))))
      (SETQ SP (CDR (ASSOC 13 SD-DXF))
     EP (CDR (ASSOC 14 SD-DXF))
     ESPL (DISTANCE SP EP)
     SEA (ANGLE SP EP)
     SEB (ANGLE EP SP)
     NEW-T (getdist "\n new length:"))
      (while (eq nil NEW-T)
 (setq  NEW-T (getdist "\n new length:")))
      (if NEW-T
 (progn
      (setq BLB (* 0.5 (abs (-  NEW-T ESPL))))
      (if (> ESPL NEW-T )
 (setq N-SP (POLAR SP SEA BLB)
       N-EP (POLAR EP (+ PI SEA) BLB))
 (setq N-SP (POLAR SP SEB BLB)
       N-EP (POLAR EP (+ PI SEB) BLB))
 )
      (setvar "osmode" (logior (getvar "osmode") 16384))
      (setvar "cmdecho" 0)
      (vl-cmdf "_.undo" "_group")
      (SETQ SS1 (SSGET "C" (POLAR SP (+ PI (* 0.25 PI)) 0.4)(POLAR SP (* 0.25 PI) 0.4))
     SS2 (SSGET "C" (POLAR EP (+ PI (* 0.25 PI)) 0.4)(POLAR EP (* 0.25 PI) 0.4))
     )
      (IF SS1
 (COMMAND "STRETCH" (SSGET "C" (POLAR SP (+ PI (* 0.25 PI)) 0.4)(POLAR SP (* 0.25 PI) 0.4))
   ""SP N-SP))
      (IF SS3
 (COMMAND "STRETCH" (SSGET "C" (POLAR EP (+ PI (* 0.25 PI)) 0.4)(POLAR EP (* 0.25 PI) 0.4))
   ""EP N-EP))
      (vl-cmdf "_.undo" "_end")
      (setvar "osmode" (logand (getvar "osmode") 49151))
      (PRINC"\n write by me \n Dimension Driven Complete, Thanks!")))
      )
    )
  (princ)
  )
Title: Re: Need help--About Dimension Driven
Post by: pBe on November 22, 2010, 02:59:12 AM
Funny how you wanted it the other way around. updating entities based on changes on dimension  :-)

But there might be  way to do that, try looking into object reactors. not sure it will work.

There are restriction to this though,(like prompting for input), i suggest you read Reactor Use Guidelines on Autocad Help

http://www.afralisp.net/ (http://www.afralisp.net/)  turorilas for Reactors






Title: Re: Need help--About Dimension Driven
Post by: Harrie on November 28, 2010, 12:15:07 PM
http://forums.augi.com/showthread.php?t=126169&highlight=hofcad
http://forums.augi.com/showthread.php?t=55713&page=5&highlight=Driven
Title: Re: Need help--About Dimension Driven
Post by: xiaxiang on November 28, 2010, 09:29:35 PM
Thanks,I will try to do my best.Any other suggestion?
Title: Re: Need help--About Dimension Driven
Post by: hermanm on December 04, 2010, 11:21:48 PM
If you have AutoCAD 2011, you can use a constraint, which is actually a type of dimension.

You can programmatically change the constrain expression, thus:

Code: [Select]
Command: Specify opposite corner:
Command: (vlax-put obj 'DimConstrExpression "80")

Then, if you have DIMASSOC - 2

a DIMENSION object associated with the constrained object, such as a line, will automatically update.

Unfortunately, you cannot use the constraint to directly dimension the object.

Interestingly, if you dump the properties of an ordinary DIMENSION in 2011, you get something like this:

Code: [Select]
Select object: ; IAcadDimRotated2: AutoCAD Rotated Dimension Interface
; Property values:
;   AltRoundDistance = 0.0
;   AltSubUnitsFactor = 100.0
;   AltSubUnitsSuffix = ""
;   AltSuppressLeadingZeros = 0
;   AltSuppressTrailingZeros = 0
;   AltSuppressZeroFeet = -1
;   AltSuppressZeroInches = -1
;   AltTextPrefix = ""
;   AltTextSuffix = ""
;   AltTolerancePrecision = 2
;   AltToleranceSuppressLeadingZeros = 0
;   AltToleranceSuppressTrailingZeros = 0
;   AltToleranceSuppressZeroFeet = -1
;   AltToleranceSuppressZeroInches = -1
;   AltUnits = 0
;   AltUnitsFormat = 2
;   AltUnitsPrecision = 2
;   AltUnitsScale = 25.4
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00e35c18>
;   Arrowhead1Block = "OBLIQUE"
;   Arrowhead1Type = 5
;   Arrowhead2Block = "OBLIQUE"
;   Arrowhead2Type = 5
;   ArrowheadSize = 0.09375
;   DecimalSeparator = "."
;   DimConstrDesc = Exception occurred
;   DimConstrExpression = Exception occurred
;   DimConstrForm = 0
;   DimConstrName = Exception occurred
;   DimConstrReference = 0
;   DimConstrValue = Exception occurred
;   DimensionLineColor = 0
;   DimensionLineExtend = 0.0
;   DimensionLinetype = "ByBlock"
;   DimensionLineWeight = -2
;   DimLine1Suppress = 0
;   DimLine2Suppress = 0

;  <etc>>

Title: Re: Need help--About Dimension Driven
Post by: xiaxiang on December 05, 2010, 08:38:10 PM
Thanks!But 2011.. I think that it was a version far away from me  :laugh: I used 2006
Title: Re: Need help--About Dimension Driven
Post by: cmwade77 on December 06, 2010, 11:35:26 AM
Newer versions would be the way to go, there are constraints, better grips that allow you to change the length of lines (then the dimension would automatically change).