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

0 Members and 1 Guest are viewing this topic.

Spike Wilbury

  • Guest
Re: H.O.S.E. problem
« Reply #15 on: December 18, 2008, 05:24:51 PM »
I see that all like it....

Maybe it is me, .... but does not work for me.

It does the first time, but after playing with the routine for a little, and then I select on the fly the angle toggle, does that, and then I try the Style, it does nothing and I get out of the loop, and try to do the dynamic edition and nada, niep, nil....

Very sorry.  :oops:

Andrea

  • Water Moccasin
  • Posts: 2372
Re: H.O.S.E. problem
« Reply #16 on: December 18, 2008, 05:31:58 PM »
nice...

for comment..
you can not rotate the hatch without scaling..
and can not scale without rotating..

this is a little handy when time is come to have the good scale in good rotation.

I suggest to have something like..
[Hatch / Scale / Angle toggle]

so you can switch as demand..

Also,..i have added some options in H.O.S. rel. 2 the ORTHOMODE was very useful here.

 :wink:
Keep smile...

T.Willey

  • Needs a day job
  • Posts: 5251
Re: H.O.S.E. problem
« Reply #17 on: December 18, 2008, 06:00:29 PM »
Thanks Ron and Kerry.  I like the fact that my skills have grown since belonging to this site.  I have seen and studied peoples code who I admire, and taken what I like from it.

Luis,

  Can you post a drawing of it not working?  Also what version are you testing it on?  I have toggled the angle on and off many times, and have not come across the issues you have.  It should always scale, but the style ( s ) and the angle ( a ) should always work.  Maybe the drawing you post will show me the issues you are having, so that we can get it fixed.

Andrea,

  I was thinking that, the option to toggle the scale.  I have it in mind already, so it should be an easy fix.  I thought about the orthomode, and was thinking about do it.  We shall see what I have time to add.   :-)  I'll look at your code when I get a chance.  Real work has been handed to me.
Tim

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

Please think about donating if this post helped you.

Spike Wilbury

  • Guest
Re: H.O.S.E. problem
« Reply #18 on: December 18, 2008, 06:09:04 PM »
Luis,

  Can you post a drawing of it not working?  Also what version are you testing it on?  I have toggled the angle on and off many times, and have not come across the issues you have.  It should always scale, but the style ( s ) and the angle ( a ) should always work.  Maybe the drawing you post will show me the issues you are having, so that we can get it fixed.


Tried with the last one posted here.

Select the hatch and see if works... I might say, it works in general, but after having or left a hatched area like the sample uploaded, it does not as far of my tests (or for me) :)
« Last Edit: December 18, 2008, 06:12:16 PM by LE »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: H.O.S.E. problem
« Reply #19 on: December 18, 2008, 06:34:35 PM »
Luis,

  Can you post a drawing of it not working?  Also what version are you testing it on?  I have toggled the angle on and off many times, and have not come across the issues you have.  It should always scale, but the style ( s ) and the angle ( a ) should always work.  Maybe the drawing you post will show me the issues you are having, so that we can get it fixed.


Tried with the last one posted here.

Select the hatch and see if works... I might say, it works in general, but after having or left a hatched area like the sample uploaded, it does not as far of my tests (or for me) :)

It works Luis, but the scale factor is so large, and the area to hatch is so small, that you can't see the changes really.  Maybe if there is an option for a scale factor, so you can type a factor in, and it will divide the current scale amount by that factor.
Tim

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

Please think about donating if this post helped you.

Spike Wilbury

  • Guest
Re: H.O.S.E. problem
« Reply #20 on: December 18, 2008, 06:41:34 PM »
It works Luis, but the scale factor is so large, and the area to hatch is so small, that you can't see the changes really.  Maybe if there is an option for a scale factor, so you can type a factor in, and it will divide the current scale amount by that factor.

Don't worried, it is fine for me - don't know if I will use the tool.



I was doing the test, inside of a detail drawing (3"=1'-0")

As normal, keep doing the good stuff!

Thanks.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: H.O.S.E. problem
« Reply #21 on: December 18, 2008, 07:14:16 PM »
Some scales will cause problems with some patterns.
See attached my attempt to deal with the scale.
I made the Base Point offset by the scale factor so it doesn't start at zero.
Still have problems with some patterns where there range of usefull  scale is 0.1 to 2.
Also added a timer to detect pattern getting too dense.

Obviously you needent use any of this as I was just tinkering around.
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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: H.O.S.E. problem
« Reply #22 on: December 18, 2008, 07:17:10 PM »
It works Luis, but the scale factor is so large, and the area to hatch is so small, that you can't see the changes really.  Maybe if there is an option for a scale factor, so you can type a factor in, and it will divide the current scale amount by that factor.

Don't worried, it is fine for me - don't know if I will use the tool.



I was doing the test, inside of a detail drawing (3"=1'-0")

As normal, keep doing the good stuff!

Thanks.
I like a challenge Luis, so I had to figure out how to do it.  Now you can toggle the Scale ( s ), Angle ( a ), Scale factor ( f ) and the Pattern ( t ).  If you toggle off the scale and angle, then it will not draw the reference line ( but if you update the scale factor it will redraw the pattern ), so you can get a true look at your pattern.  I change the call to DHE ( dynamic hatch edit ).  Maybe orthomode next, or origin like Andrea is doing with his code.   :wink:  We shall see.

I thing I don't like is how the prompt comes across.  I wanted to put it on two lines, but with prompt that wouldn't work with the ' \r ' switch.  I will see what I can find out later.  For now this is going in my code bag.   :-)

Code: [Select]
(defun c:DHE ( / *error* GetHatchNames Sel Ent EntData oData nStyle cScale BasePt HatchList Pos
    TogAngle tempList tempPt tempData MaxPos TogScale ScFac )
    ; 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)
    )
    ;------------------------------------
    (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.)
        )
        (while
            (and
                (not
                    (prompt
                        (strcat
                            "\r Pattern: "
                            nStyle
                            " , Change angle: "
                            (if (zerop TogAngle) "No" "Yes")
                            " , Change scale: "
                            (if (zerop TogScale) "No" "Yes")
                            " , Scale factor: "
                            (rtos ScFac 2 4)
                            " [paTtern / Scale toggle / scale Factor / Angle toggle]: "
                        )
                    )
                )
                (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))
                    (if (not (zerop (distance tempPt BasePt))) ; <- Thanks to Alan ( CAB )
                        (progn
                            (redraw)
                            (if
                                (or
                                    (equal TogScale 1)
                                    (equal TogAngle 1)
                                )
                                (grdraw BasePt tempPt 7)
                            )
                            (setq tempData EntData)
                            (if (equal TogScale 1)
                                (setq tempData
                                    (subst
                                        (cons
                                            41
                                            ;(distance tempPt BasePt)
                                            (* (distance tempPt BasePt) cScale ScFac)
                                        )
                                        (assoc 41 tempData)
                                        tempData
                                    )
                                )
                            )
                            (if (equal TogAngle 1)
                                (setq tempData
                                    (subst
                                        (cons 52 (angle BasePt tempPt))
                                        (assoc 52 tempData)
                                        tempData
                                    )
                                )
                            )
                            (if (entmake tempData)
                                (progn
                                    (entdel Ent)
                                    (setq Ent (entlast))
                                )
                            )
                        )
                    )
                )
                ((equal (car tempList) 2)
                    (cond
                        ( (member (cadr tempList) '(84 116))
                            (if (equal Pos MaxPos)
                                (setq Pos 0)
                            )
                            (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))
                            (setq TogAngle (abs (1- TogAngle)))
                        )
                        ( (member (cadr tempList) '(83 115))
                            (setq TogScale (abs (1- TogScale)))
                        )
                        ( (member (cadr tempList) '(40 102))
                            (setq ScFac
                                (cond
                                    ( (getreal (strcat "\n Enter scale factor <" (rtos ScFac 2 4) ">: ")) )
                                    (t ScFac)
                                )
                            )
                            (if
                                (entmake
                                    (subst
                                        (cons
                                            41
                                            ;(distance tempPt BasePt)
                                            (* (distance tempPt BasePt) cScale ScFac)
                                        )
                                        (assoc 41 EntData)
                                        EntData
                                    )
                                )
                                (progn
                                    (entdel Ent)
                                    (setq Ent (entlast))
                                )
                            )
                        )
                    )
                )
            )
        )
    )
    (redraw)
    (princ)
)
Tim

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

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: H.O.S.E. problem
« Reply #23 on: December 18, 2008, 07:23:11 PM »
I like the ideas you have in your code Alan.  I was just trying to make it all one handed, so I can have my right hand on the mouse, and my left answering the prompts.  I have seen some of the problems with the scale being too small, so the timer is a good fix.  I will test more tomorrow when I get a chance.
Tim

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

Please think about donating if this post helped you.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: H.O.S.E. problem
« Reply #24 on: December 18, 2008, 07:57:13 PM »
maybe by putting the CMDECHO to 0 you didn't see the

"Hatch boundary associativity removed." message..

(setvar "CMDECHO" 0)

 :-)

by the way...DHE is more appropriate....I was thinking to rename the H.O.S. to Dhatch for DynamicHATCH or (the Hatch)  ;-)
« Last Edit: December 18, 2008, 10:09:07 PM by Andrea »
Keep smile...

T.Willey

  • Needs a day job
  • Posts: 5251
Re: H.O.S.E. problem
« Reply #25 on: December 19, 2008, 01:57:35 PM »
I do see the message now.  I didn't know that they first tests I was doing was on non-associated hatches.  I will see if I can figure out how to keep them associated if they are.  Here is a new version that has the ortho honored, and a new prompt.  It will let you go forward or backward in the hatch patter list.  Options are now as followed; f = forward pattern, r = back ( reverse ) pattern, a = angle, s = scale, c = scale factor

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)
    )
    ;------------------------------------
    (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))
        )
        (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))))
                        )
                    )
                )
            )
        )
    )
    (redraw)
    (princ)
)
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: 7529
Re: H.O.S.E. problem
« Reply #26 on: December 19, 2008, 02:49:26 PM »
Tim,

You could probably just make the hatch with the vl-functions after you get out of the grread and delete the last entmake hatch to make it associative.

*tested here and it worked

*nevermind...I forgot that you are editing existing hatch and not adding to an object

Ron
« Last Edit: December 19, 2008, 03:25:28 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

T.Willey

  • Needs a day job
  • Posts: 5251
Re: H.O.S.E. problem
« Reply #27 on: December 19, 2008, 03:38:19 PM »
You did get me thinking though, but that idea didn't work either.  I tried to make the current hatch invisible, and then change it after all was done, but
' entmod ' still wouldn't work, even in '08.  I'll see if I can find a way after lunch.
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: 7529
Re: H.O.S.E. problem
« Reply #28 on: December 19, 2008, 04:55:25 PM »
Tim,

Something to mull over...I'm sure you can come up with a more elegant solution  :-P but this worked for me:

Code: [Select]
(setq h (vlax-ename->vla-object (car (entsel))))

(setq obj (getassochatchobjs (car (entsel))))

(vl-catch-all-error-p
  (vl-catch-all-apply 'vlax-invoke
                      (list h 'appendouterloop obj)
  )
)


(defun getassochatchobjs (hatchent /)
  (mapcar 'vlax-ename->vla-object
          (mapcar 'cdr
                  (vl-remove-if-not
                    '(lambda (x)
                       (and (= 330 (car x))
                            (/= (cdr (assoc 0 (entget (cdr x)))) "BLOCK_RECORD")
                       )
                     )
                    (entget hatchent)
                  )
          )
  )
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

T.Willey

  • Needs a day job
  • Posts: 5251
Re: H.O.S.E. problem
« Reply #29 on: December 19, 2008, 06:44:14 PM »
Ron,

  I was trying to do something like that with Lisp, and I could get it to work with polylines, but not with lines or circles, eventhough the code said it did.  I'll add this and see if it works.  I think it will.  I'm just being stubborn, and trying to use just vanilla Lisp.

Thanks.
Tim

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

Please think about donating if this post helped you.