cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

The PTC Community email address has changed to community-mailer@ptc.com. Learn more.

Macros that do things - even when told not to!

TimSharp
6-Contributor

Macros that do things - even when told not to!

There are two problems I've come across with Isodraw macros that I'm hoping someone can help with.

1. I have several macros that repeat - where you select items on an illustration one after the other and the macro makes a change each time.

The problem on all these macros is that after about the 5th time you select an item (within a while loop), it insists on refreshing the screen every time you select something.

2. Some macros I have specifically put "select none" at the end but it still leaves lines selected when the macro is finished.

3. I have another macro where you select 2 beziers on the illustration and the macro insists on changing the pens of these beziers. The first one becomes medium, the 2nd one becomes thin - though nothing in the macro changes the pens.

Has anyone else come across this behaviour in their macros and did you find a way round them?

8 REPLIES 8

In regards to #1 is that I've seen this and actually have a macro that's been running fine for about 4-5 years and is now experiencing this (we just upgraded to 7.3, F00). No solution yet though. What happens with mine is that after the roughly fifth click the screen refreshes and the pointer changes to a 'processing' icon and does not let go.

In regards to two, I've found that sometimes double-stacking select nones on each other works (use two).

For three, you're likely going to need to post the macro for much troubleshooting. Might be simple but without seeing the steps it's just a wild guess.

TimSharp
6-Contributor
(To:thendricks)

Thanks for your help Trevor

1. We're still using 7.0 and it's always done this - we don't get the 'processing' icon up though, just the screen refreshes. It's an annoying habit of Isodraw this, and though it doesn't stop the macro working, it makes it uncomfortable for the illustrator to use.

2. Unfortunately , repeating 'select none' doesn't work in this macro - wierd why Isodraw ignores commands isn't it?

3. I'll have to try to cut down this macro to illustrate the problem - it's unfinished and rather long winded at the moment.

#2, hasn't always worked but generally has just been something we've lived with. The other thing I might try, haven't myself though, is to do a final select based on something you'd never find. Perhaps a select if based on a funky ID or something similar. Should result in nothing being selected.

#3, be careful on cutting back too far. I've done that myself and have accidentally removed the cause the problem in the process.

TimSharp
6-Contributor
(To:thendricks)

2. I'll try that, thanks

3. Yes, I'll be careful - though I guess it would narrow down where the problem is!

TimSharp
6-Contributor
(To:thendricks)

I've added the macro below, there are notes in it towards the end that are relevant to the problem of it changing lines.

#THIS IS TO ADD A NO-PEN LINE TO ENDS OF A PAIR OF PARALLEL BEZIERS AND THEN ADD WHITE FILL (CAN GET IT TO ADD CONTOUR BUT DON'T KNOW ABOUT SETTING THE FILL TYPE), THEN GROUPING BEZIERS AND CONTOUR.

macro join_bezier_ends_test

Define exit_loop as String

Define first_bezier as Element

Define second_bezier as Element

Define contour as Element

define first_bezier_picked_x as element

define first_bezier_picked_y as element

define second_bezier_picked_x as element

define second_bezier_picked_y as element

define end1 as element # FIRST END LINE

define end2 as element # SECOND END LINE

define me as MouseEvent

exit_loop = "no"

While (exit_loop = "no")

me = Wait MouseClick

Select at me.ptmm.x me.ptmm.y Direct

first_bezier_picked_x = me.ptmm.x

first_bezier_picked_y = me.ptmm.y

# NEED TO MAKE VARIABLES OF THE X AND Y PICKED POINTS FOR BOTH BEZIERS SO END LINES CAN BE DRAWN

first_bezier = ActiveDoc.FirstSelectedElement

If (first_bezier.type = "Bezier")

exit_loop = "yes"

# ADDS INFO TO BEZIER TO EASE GROUPING LATER

Create Object_Info first_bezier

Create Object_Attribute "join_bez" "String" first_bezier

first_bezier.Info.Attributes["join_bez"].Value = "bez B1"

# HERE IT WORKS OUT POSITION OF START AND END POINTS OF 1ST BEZIER

define seg_count as float

seg_count = first_bezier.SegmentCount

define first_bezier_startX as point

define first_bezier_startY as point

define first_bezier_EndX as point

define first_bezier_EndY as point

first_bezier_StartX = first_bezier.bezier.startPoint.x

first_bezier_StartY = first_bezier.bezier.startPoint.Y

first_bezier_EndX = first_bezier.bezier.segments[seg_count].endPoint.x

first_bezier_EndY = first_bezier.bezier.segments[seg_count].endPoint.Y

End If

If (exit_loop = "no")

message 'The First Bezier Was Not Selected - Start Again'

Select None

Debug Reset

End If

End While

exit_loop = "no"

While (exit_loop = "no")

me = Wait MouseClick

Select at me.ptmm.x me.ptmm.y Direct

second_bezier_picked_x = me.ptmm.x

second_bezier_picked_y = me.ptmm.y

second_bezier = ActiveDoc.FirstSelectedElement

If (second_bezier.type = "Bezier")

exit_loop = "yes"

# ADDS INFO TO BEZIER TO EASE GROUPING LATER

Create Object_Info second_bezier

Create Object_Attribute "join_bez" "String" second_bezier

second_bezier.Info.Attributes["join_bez"].Value = "bez B2"

# HERE IT WORKS OUT POSITION OF START AND END POINTS OF 2ND BEZIER

seg_count = second_bezier.SegmentCount

define second_bezier_startX as point

define second_bezier_startY as point

define second_bezier_EndX as point

define second_bezier_EndY as point

second_bezier_StartX = second_bezier.bezier.startPoint.x

second_bezier_StartY = second_bezier.bezier.startPoint.Y

second_bezier_EndX = second_bezier.bezier.segments[seg_count].endPoint.x

second_bezier_EndY = second_bezier.bezier.segments[seg_count].endPoint.Y

End If

If (exit_loop = "no")

message 'The Second Bezier Was Not Selected - Start Again'

Select None

Debug Reset

End If

End While

# NOW ADD LINES ACROSS THE ENDS

create line first_bezier_StartX first_bezier_StartY second_bezier_StartX second_bezier_StartY

end1 = ActiveDoc.FirstSelectedElement

Create Object_Info end1

Create Object_Attribute "join_bez" "String" end1

end1.Info.Attributes["join_bez"].Value = "bez end1"

create line first_bezier_endX first_bezier_endY second_bezier_endX second_bezier_endY

end2 = ActiveDoc.FirstSelectedElement

Create Object_Info end2

Create Object_Attribute "join_bez" "String" end2

end2.Info.Attributes["join_bez"].Value = "bez end2"

#NOW SELECT THE BEZIERS AND THE END LINES TO GENERATE CONTOUR

Select If Object_Attribute_Value "join_bez" contains "bez"

#HOW DO I SET IT SO THE CONTOUR HAS WHITE FILL?

Generate contour

contour = ActiveDoc.FirstSelectedElement

Create Object_Info contour

Create Object_Attribute "join_bez" "String" contour

contour.Info.Attributes["join_bez"].Value = "bez C1"

Arrange bottom

Select None

#NOW REMOVE THE END LINES

Select If Object_Attribute_Value "join_bez" contains "end"

Delete selection

#NOW SELECT BEZIERS, AND CONTOUR TO GROUP

Select If Object_Attribute_Value "join_bez" contains "bez"

Group Selection

wait mouseclick

# THIS JUST ADDED TO ILLUSTRATE THAT LINES ARE STILL CORRECT AT THIS POINT - BEZIER LINES ARE UNCHANGED, CONTOUR IS NO LINE. AS SOON AS YOU CLICK THE MOUSE, THE MACRO ENDS AND ALL THE LINES BECOME THIN. IS THIS BEING DONE AFTER THE MOUSECLICK OR IS IT SOMETHING EARLIER THAT'S CHANGING LINES BUT ONLY BECOMING APPARENT AT THE END OF THE MACRO?

#I'VE COMMENTED OUT THE REMAINING ACTIONS TO ILLUSTRATE THAT IT STILL CHANGES LINE TYPES EVEN WHEN NOTHING MORE IS DONE

#Select If Object_Attribute_Value "join_bez" contains "bez"

#delete object_info deep

#Select None

end macro

TimSharp
6-Contributor
(To:TimSharp)

Any comments Trevor?

Sorry. Got pulled full time on a project and haven't gotten to spend much time looking at the forum.

Try commenting out the Group Selection towards the end. I've noticed that grouping during the macro run can have issues. See if you get similar results.

I'll see if I can break away in the next day or two try it locally as well.

TimSharp
6-Contributor
(To:thendricks)

Thanks Trevor, I get busy like that at times too!

Still happens if I remove the grouping. I wonder if it's something to do with infos?