Author Topic: H.O.S.E. problem  (Read 10864 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: H.O.S.E. problem
« Reply #30 on: December 19, 2008, 07:40:16 PM »
That didn't seem to work for me Ron, I think I used it right, within the command, but it did from outside of it.  Not sure if it's an '06 thing or not.  Here is what I have so far, and I might work on it some more, but I might just leave it.  It seems to keep the associativeness with polylines ( closed tested only ), but nothing else.  I have not found a way to have it not assualt the command line with ' Hatch boundary associativity removed. ', which can take up the whole history.  Oh well.

Code: [Select]
(defun c:DHE ( / *error* GetHatchNames Sel Ent EntData oData nStyle cScale BasePt HatchList Pos
    TogAngle tempList tempPt tempData MaxPos TogScale ScFac TogOrtho Ang45 Ang135 Ang225 Ang315 )
    ; Dynamic Hatch Edit.  Scale, rotation and pattern.
   
    (defun *error* ( msg )
       
        (vl-bt)
        (if oData (entmake oData))
        (if Ent (entdel Ent))
        (if msg (prompt (strcat "\n Error-> " msg)))
        (redraw)
    )
    ;--------------------------------
    (defun GetHatchNames ( filePath / Opened tempStr tempPos tempName HatchList )
       
        (if (setq Opened (open filePath "r"))
            (while (setq tempStr (read-line Opened))
                (if
                    (and
                        (= (substr tempStr 1 1) "*")
                        (setq tempPos (vl-string-search "," tempStr))
                        (setq tempName (substr tempStr 2 (1- tempPos)))
                        (/= (strcase tempName) "SOLID")
                    )
                    (setq HatchList (cons tempName HatchList))
                )
            )
        )
        (if Opened (close Opened))
        (reverse HatchList)
    )
    ;------------------------------------
    (defun UpdateHatchReactor ( ent oHatEnt nHatEnt / EntData EndList StList )
       
        (setq EntData (entget ent))
        (if (member (cons 330 oHatEnt) EntData)
            (entmod (subst (cons 330 nHatEnt) (cons 330 oHatEnt) EntData))
            (progn
                (setq EndList (member (assoc 5 EntData) EntData))
                (setq StList (reverse (member (car EndList) (reverse EntData))))
                (setq EndList (cdr EndList))
                (entmod
                    (append
                        StList
                        (append
                            (list
                                '(102 . "{ACAD_REACTORS")
                                (cons 330 nHatEnt)
                                '(102 . "}")
                            )
                            EndList
                        )
                    )
                )
            )
        )
    )
    ;------------------------------------
    (if
        (and
            (setq Sel (entsel "\n Select hatch to edit dynamicly: "))
            (setq oData (entget (car Sel)))
            (= (cdr (assoc 0 oData)) "HATCH")
            (setq nStyle (cdr (assoc 2 oData)))
            (setq cScale (cdr (assoc 41 oData)))
            (setq BasePt (cadr Sel))
            (setq HatchList
                (GetHatchNames
                    (if (zerop (getvar 'Measurement))
                        (findfile "acad.pat")
                        (findfile "acadiso.pat")
                    )
                )
            )
            (setq MaxPos (1- (length HatchList)))
            (setq Pos (vl-position nStyle HatchList))
            (setq TogScale 1)
            (setq TogAngle 0)
            (setq ScFac 1.)
            (setq TogOrtho (getvar 'OrthoMode))
            (setq Ang45 (* pi 0.25))
            (setq Ang135 (* pi 0.75))
            (setq Ang225 (* pi 1.25))
            (setq Ang315 (* pi 1.75))
        )
        (progn
            (while
                (and
                    (princ
                        (strcat
                            "\r pattern: "
                            nStyle
                            " [Forward / Reverse], change Angle: "
                            (if (zerop TogAngle) "No" "Yes")
                            " , change Scale: "
                            (if (zerop TogScale) "No" "Yes")
                            " , sCale factor: "
                            (rtos ScFac 2 4)
                        )
                    )
                    (setq tempList (grread T 11))
                    (not (equal (car tempList) 3))
                )
                (or
                    Ent
                    (setq Ent (car Sel))
                )
                (setq EntData (entget Ent '("*")))
                (cond
                    ( (equal (car tempList) 5)
                        (setq tempPt (cadr tempList))
                        (setq tempAng (angle BasePt tempPt))
                        (setq tempAng
                            (if (zerop TogOrtho)
                                tempAng
                                (cond
                                    (
                                        (or
                                            (<= tempAng Ang45)
                                            (>= tempAng Ang315)
                                        )
                                        0.0
                                    )
                                    ( (<= Ang45 tempAng Ang135)
                                        (* pi 0.5)
                                    )
                                    ( (<= Ang135 tempAng Ang225)
                                        pi
                                    )
                                    ( (<= Ang225 tempAng Ang315)
                                        (* pi 1.5)
                                    )
                                )
                            )
                        )
                        (setq tempPt (polar BasePt tempAng (distance BasePt tempPt)))
                        (if (not (zerop (distance tempPt BasePt))) ; <- Thanks to Alan ( CAB )
                            (progn
                                (redraw)
                                (if
                                    (or
                                        (equal TogScale 1)
                                        (equal TogAngle 1)
                                    )
                                    (grdraw BasePt tempPt 1 1)
                                )
                                (setq tempData EntData)
                                (if (equal TogScale 1)
                                    (setq tempData
                                        (subst
                                            (cons
                                                41
                                                (* (distance tempPt BasePt) cScale ScFac)
                                            )
                                            (assoc 41 tempData)
                                            tempData
                                        )
                                    )
                                )
                                (if (equal TogAngle 1)
                                    (setq tempData
                                        (subst
                                            (cons 52 tempAng)
                                            (assoc 52 tempData)
                                            tempData
                                        )
                                    )
                                )
                                (if (entmake tempData)
                                    (progn
                                        (entdel Ent)
                                        (setq Ent (entlast))
                                    )
                                )
                            )
                        )
                    )
                    ((equal (car tempList) 2)
                        (cond
                            ( (member (cadr tempList) '(40 102)) ; F pushed
                                (if (equal Pos MaxPos)
                                    (setq Pos -1)
                                )
                                (setq nStyle (nth (setq Pos (1+ Pos)) HatchList))
                                (if (entmake
                                        (subst
                                            (cons 2 nStyle)
                                            (assoc 2 EntData)
                                            EntData
                                        )
                                    )
                                    (progn
                                        (entdel Ent)
                                        (setq Ent (entlast))
                                    )
                                )
                            )
                            ( (member (cadr tempList) '(82 114)) ; R pushed
                                (if (zerop Pos)
                                    (setq Pos (1+ MaxPos))
                                )
                                (setq nStyle (nth (setq Pos (1- Pos)) HatchList))
                                (if (entmake
                                        (subst
                                            (cons 2 nStyle)
                                            (assoc 2 EntData)
                                            EntData
                                        )
                                    )
                                    (progn
                                        (entdel Ent)
                                        (setq Ent (entlast))
                                    )
                                )
                            )
                            ( (member (cadr tempList) '(65 97)) ; A pushed
                                (setq TogAngle (abs (1- TogAngle)))
                            )
                            ( (member (cadr tempList) '(83 115)) ; S pushed
                                (setq TogScale (abs (1- TogScale)))
                            )
                            ( (member (cadr tempList) '(67 99)) ; C pushed
                                (setq ScFac
                                    (cond
                                        ( (getreal (strcat "\n Enter scale factor <" (rtos ScFac 2 4) ">: ")) )
                                        (t ScFac)
                                    )
                                )
                                (if
                                    (entmake
                                        (subst
                                            (cons
                                                41
                                                (* (distance tempPt BasePt) cScale ScFac)
                                            )
                                            (assoc 41 EntData)
                                            EntData
                                        )
                                    )
                                    (progn
                                        (entdel Ent)
                                        (setq Ent (entlast))
                                    )
                                )
                            )
                            ( (equal (cadr tempList) 15) ; F8 pushed
                                (setvar 'OrthoMode (setq TogOrtho (abs (1- TogOrtho))))
                            )
                        )
                    )
                )
            )
            (setq Ent (entlast))
            (foreach i (cdr (member '(100 . "AcDbHatch") (entget Ent)))
                (if (equal (type (cdr i)) 'ENAME)
                    (UpdateHatchReactor (cdr i) (cdr (assoc -1 oData)) Ent)
                    ;(setq EntList (cons (cdr i) EntList))
                )
            )
            ;|
            (if EntList
                (vlax-invoke (vlax-ename->vla-object Ent) 'AppendOuterLoop (apply 'vlax-ename->vla-object EntList))
            )
            (setq EntList nil)|;
        )
    )
    (redraw)
    (princ)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: H.O.S.E. problem
« Reply #31 on: December 21, 2008, 07:14:01 PM »
Worked well here Tim with ACAD2000 & no message 'Hatch boundary associativity removed'
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: H.O.S.E. problem
« Reply #32 on: December 21, 2008, 10:16:52 PM »
tested on 2009..
Keep smile...

Andrea

  • Water Moccasin
  • Posts: 2372
Re: H.O.S.E. problem
« Reply #33 on: December 21, 2008, 10:21:09 PM »
tested on 2009 with CMDECHO set to 0..

Keep smile...

Andrea

  • Water Moccasin
  • Posts: 2372
Re: H.O.S.E. problem
« Reply #34 on: December 21, 2008, 11:19:43 PM »
For comment..

I've made some test on 2009.

- Rotation do also a scale..
- Rotation do not alway follow the hatch pattern
- Scale do also a rotation.
- ORTHO work only 0 90 180 180 and do not follow the SNAPANG variable.

don't know if it is the same on older release..




Keep smile...

T.Willey

  • Needs a day job
  • Posts: 5251
Re: H.O.S.E. problem
« Reply #35 on: December 22, 2008, 11:05:09 AM »
Thanks for testing Alan.  Good to hear it works there.

Andrea,

  I thought about following the SnapAng variable, but didn't do it just because I don't change it very often.  That shouldn't get a change too hard to make though.  I'll see about adding it.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ronjonp

  • Needs a day job
  • Posts: 7527
Re: H.O.S.E. problem
« Reply #36 on: December 22, 2008, 11:18:13 AM »
For comment..

I've made some test on 2009.

- Rotation do also a scale..
- Rotation do not alway follow the hatch pattern
- Scale do also a rotation.
- ORTHO work only 0 90 180 180 and do not follow the SNAPANG variable.

don't know if it is the same on older release..


FWIW...Tim I do not see any of these issues in 09 everything appears to work fine. The only drawback is the non-assoc hatch created with objects other that a polyline.

Ron





[/quote]

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

T.Willey

  • Needs a day job
  • Posts: 5251
Re: H.O.S.E. problem
« Reply #37 on: December 22, 2008, 12:14:31 PM »
Thanks Ron.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.