Macro help Log Out | Topics | Search
Moderators | Edit Profile

CADVANCE USERS FORUM » CADVANCE Forum » Macro help « Previous Next »

  Thread Last Poster Posts Pages Last Post
Need Help with layersMilo Holroyd12-12-06  03:17 am
  Start New Thread        

Author Message
Top of pagePrevious messageNext messageBottom of page Link to this message

Jeff_hayden
Username: Jeff_hayden

Registered: 09-2006
Posted From: 216.62.125.199
Posted on Monday, January 21, 2008 - 07:10 am:   

Is is possible to insert a macro into a drawing so a user can click on an object in the drawing to run the macro?
Top of pagePrevious messageNext messageBottom of page Link to this message

Ken_etter
Username: Ken_etter

Registered: 08-2006
Posted From: 205.196.151.98
Posted on Tuesday, March 27, 2007 - 01:01 am:   

Jeff,

The only thing I can think of for your linestyle issue is that you have a linestyle assigned to some of the layers. When your macro changes to that layer, the linestyle is changed also. Regardless of whether or not that is the cause, I would think the simple fix is to do a cdigetstyle at the beginning to find the current active linestyle and then do a cdisetstyle at the end to make sure the macro leaves it the way you want it.

Ken
Top of pagePrevious messageNext messageBottom of page Link to this message

Jeff_hayden
Username: Jeff_hayden

Registered: 09-2006
Posted From: 216.62.125.199
Posted on Monday, March 26, 2007 - 10:17 am:   

Is there a way to have a macro change the current search path for a symbol?

When I go to "Options-Path-Symbol Paths 1-8" I want path #1 to be the default search location but it keeps changing (I think after someone translates a drawing which dumps symbols in another path). Can I have a macro that will change the search column back the path #1?

Thank you.
Top of pagePrevious messageNext messageBottom of page Link to this message

Jeff_hayden
Username: Jeff_hayden

Registered: 09-2006
Posted From: 216.62.125.199
Posted on Thursday, January 25, 2007 - 11:05 am:   

Well, since it has been so quiet around the forum, I am going to seek some macro advice.

The macro below is used for demolishing objects in a drawing- we click on a line that represents a wall or millwork or whatever and the macro changes the selected object to the demo layer and a dashed linestyle (linestlye #5 in this case). Most of the time it works right but in certain drawings it changes the current linestyle to the demo linestyle (#5), which means the user has to change it back manually. Normally it leaves it the way it was already set at. When it changes it, it does it as soon as the macro is launched and I can't figure out why it would only do this in certain drawings. Any clues?

Thanks for looking at it. Here is the macro:

sub main
cv_osl = 0
null_ptr = 0

dim layer as integer
dim active_layer as integer
dim layer_buffer as CDI_LAYER

'get current drawing color
xcolor = CdiGetCurColor()

' get current active layer
layer=CdiGetActLayer()
' set new layer
i_ret=CdiSetActLayer(34)
Call CdiStatusLineUpdate()

dimension_osl = CdiCreateLocalOsl(CDI_OBJECT_COLOR, null_ptr, CDI_REDRAW_OSL)
prompt_1 = "Select objects to demo them" + chr$(0)
selection_mode = CDI_SEL2D_ALL

do
call CdiClearMenuEvent()
call CdiClearMenuSelection()
i_ret =CdiSelectbyPoint(cv_osl,prompt_1,CDI_OBJECT_SELECTION,CDI_FALSE,CDI_TRUE,c1,sel ection_mode)

'//button 2 was pressed
if i_ret=CDI_ABORT then
exit do
end if

'change selected objects to color 9, demo layer, mindasha linestyle
i_ret = CdiObjColor(cv_osl, 9)
i_ret = CdiObjLayer(cv_osl, 34, CDI_HIGHLIGHT)
i_ret = CdiObjStyle(cv_osl, 5, CDI_HIGHLIGHT)
'run demo door macro to replace door symbols with demo door symbols
i_ret = CdiRunMacro("demo-dr.cbx")

call CdiOslClear (cv_osl)

loop

'restore current drawing color
i = CdiSetCurColor(xcolor)

'reset active layer
i_ret=CdiSetActLayer(layer)
Call CdiStatusLineUpdate()
call cdiputmsg ("Select object(s) for editing...")
Top of pagePrevious messageNext messageBottom of page Link to this message

Jeff_hayden
Username: Jeff_hayden

Registered: 09-2006
Posted From: 216.62.125.199
Posted on Friday, January 05, 2007 - 05:17 am:   

Ken,

Thanks. I knew I had heard of that macro before. That was exactly what I needed. Thanks for sharing it.

Jeff
Top of pagePrevious messageNext messageBottom of page Link to this message

Ken_etter
Username: Ken_etter

Registered: 08-2006
Posted From: 205.196.151.98
Posted on Thursday, January 04, 2007 - 12:09 pm:   

Jeff,

I have a macro that does that. Log into my website and download Text Replace.

Ken
Top of pagePrevious messageNext messageBottom of page Link to this message

Jeff_hayden
Username: Jeff_hayden

Registered: 09-2006
Posted From: 216.62.125.199
Posted on Thursday, January 04, 2007 - 11:13 am:   

Freshen my memory.

It seems like there was a macro somewhere that allowed a user to select several pieces of text at once and change the words all at once. For example, is some Einstein abbreviated the word Assistant as "ASS." 30 times throughout a drawing, the macro would allow you to edit them all to say "ASST." with one move.

Does that ring a bell with anybody?
Top of pagePrevious messageNext messageBottom of page Link to this message

Jeff_hayden
Username: Jeff_hayden

Registered: 09-2006
Posted From: 216.62.125.199
Posted on Thursday, December 07, 2006 - 02:01 pm:   

Joe,

I used that same macro to create those fills. Not every drawing has this issue. Sometimes I am able to select the fills with my mouse and sometimes I can't.
Top of pagePrevious messageNext messageBottom of page Link to this message

Joe_calvin
Username: Joe_calvin

Registered: 09-2006
Posted From: 8.7.87.222
Posted on Thursday, December 07, 2006 - 01:25 pm:   

Jeff,

In the example file you sent me, were the area fills created by the same version of the macro you posted here in the forum? Here's why I'm asking. If you select one of the objects (yes, by windowing) and then turn off the fill, none of the lines are visible, and that is why they cannot be selected.

You have four lines of code that read:
l_ret = CdiObjAddtoline(c2, CDI_DRAWTO)

It would appear from your drawing file however that the last parameter in these lines might have been CDI_MOVETO instead. CDI_DRAWTO and CDI_MOVETO have values of 2 and 1 respectively. Segments drawn with CDI_MOVETO are of course not visible or selectable, but will act as an area fill boundary.
Top of pagePrevious messageNext messageBottom of page Link to this message

Jeff_hayden
Username: Jeff_hayden

Registered: 09-2006
Posted From: 216.62.125.199
Posted on Thursday, December 07, 2006 - 11:13 am:   

Joe,

Thanks for taking a look at it. I have sent an example of this problem to FIT and have copied you on it. We are using V12.32. Even when I isolate the layer with the fills and ensure the layer is selectable I am still unable to select the fills by clicking on them- only with window select.

Thank you for your "picky comment". I will take any picky comments I can get as I don't know a lot about macro writing. I'm sure most of my macros are written pretty sloppily and contain lines they don't need and are missing lines they do need.

Thanks again,
Jeff
Top of pagePrevious messageNext messageBottom of page Link to this message

Joe_calvin
Username: Joe_calvin

Registered: 09-2006
Posted From: 8.7.87.222
Posted on Wednesday, December 06, 2006 - 05:27 pm:   

Hi Jeff,

I played with your macro quite a bit this evening and it worked okay for me. I was able to select the shapes by single clicking on an edge with snap turned off. Is it possible that you have some sort of layer or snap problem? I noticed that the macro sets the snap to Intersection. Is it possible that you are selecting underlying geometry instead? I drew test shapes out in the middle of space with snap turned off. The only other thing I can think of is Cadvance version. Are you using 12.32? I know FIT made some changes regarding area fill post 12.oh. Does saving, closing, and opening the file change the selectability for you. If not, send FIT a drawing file with a hard-to-select shape in it.

One last suggestion. Don't know that it will help, but I would recommend replacing the two lines starting "i_ret=cdiMenuEntry(IDM_AREA_FILL..." and the line below it with one line saying "I_ret=cdiEditAreaFill(oslobject.sid,CDI_YES)". This is a very picky comment on my part and I apologize. I generally find MenuEntry Commands a little less predictable than actual specific cdi... Commands. Also, if you have another object selected (say a circle) before running the macro as is, it will also change that circle to have area fill.

Good Luck!
Top of pagePrevious messageNext messageBottom of page Link to this message

Jeff_hayden
Username: Jeff_hayden

Registered: 09-2006
Posted From: 216.62.125.199
Posted on Tuesday, December 05, 2006 - 12:12 pm:   

I've got the macro below which fills in four selected points with Draw Oject Area Fill. Ever since upgrading to V12, I have been unable to select any fills created with this macro by picking them. I can only select the fills by windowing them. Does anyone see anything in the macro that might cause that?

sub main

cv_osl = 0
null_ptr = 0
dim c1 as CDI_DD_POINT
dim c2 as CDI_DD_POINT
dim c3 as CDI_DD_POINT
dim c4 as CDI_DD_POINT
dim oslobject as cdi_osl_object

i_ret = CdiSetSnapMode(Cdi_Intersectionsnap)
i_ret = CdiGetActLayer()
Call CdiStatusLineUpdate()

DO
c1.x=0
c1.y=0
c2.x=0
c2.y=0
c3.x=0
c3.y=0
c4.x=0
c4.y=0

i_ret=CdiGetPoint("Pick first point", c1, button_hit%, menu_hit%)
if button_hit = CDI_BUTTON_2 then exit do

i_ret=CdiGetPoint("Pick second point", c2, button_hit%, menu_hit%)
if button_hit = CDI_BUTTON_2 then exit do

i_ret=CdiGetPoint("Pick third point", c3, button_hit%, menu_hit%)
if button_hit = CDI_BUTTON_2 then exit do

i_ret=CdiGetPoint("Pick fourth point to close and fill", c4, button_hit%, menu_hit%)
if button_hit = CDI_BUTTON_2 then exit do

i_ret = CdiObjStartline(c1, cdigetactlayer(), 0, 1, cdigetcurcolor())
l_ret = CdiObjAddtoline(c2, CDI_DRAWTO)
l_ret = CdiObjAddtoline(c3, CDI_DRAWTO)
l_ret = CdiObjAddtoline(c4, CDI_DRAWTO)
i_ret = CdiObjAddtoline(c1, CDI_DRAWTO)
oslobject.sid = CdiObjEndline(CDI_TRUE, CDI_TRUE, CDI_OBJECT_COLOR)
i_ret=CdiOslAdd(cv_osl,oslobject,cdi_true)

i_ret = cdiMenuEntry(IDM_AREA_FILL,CDI_BUTTON_2,CDI_NO_MENU_ITEM)
if button_hit = CDI_BUTTON_2 then exit do

call CdiOslClear (cv_osl)

loop

i_ret = CdiSetWeight(0)
Call CdiStatusLineUpdate()
i_ret = CdiSetSnapMode(Cdi_NOsnap)
call cdiputmsg ("Select object(s) for editing...")

end sub
Top of pagePrevious messageNext messageBottom of page Link to this message

aemedwedew@earthlink.net
Username: Alexander_medwedew

Registered: 10-2006
Posted From: 4.237.176.100
Posted on Wednesday, October 04, 2006 - 06:45 am:   

This code will make active the layer of an object that has been picked.

sub main

dim object1 as CDI_OSL_OBJECT
dim pnt0 as CDI_DDD_POINT
dim l_osl as long
dim snapmode as integer

l_osl=CdiCreateLocalOsl(CDI_OBJECT_COLOR,0&, CDI_REDRAW_OSL)
select case CdiGetProgMode
case CDI_2D_MODE
snapmode=CdiGetSnapMode()
i_ret=CdiSetSnapMode(CDI_NOSNAP)
i_ret=CdiSelectbyPoint(l_osl,"Select object on layer to make active",CDI_OBJECT_SELECTION,CDI_FALSE,CDI_TRUE,pnt0,CDI_SEL2D_ALL)
if i_ret=CDI_ABORT then
i_ret=CdiFreeLocalOsl(l_osl&)
exit sub
end if
i_ret=CdiOslItem(l_osl&, 0, object1)
i_ret=CdiObjType(object1.sid,obj_type%,layer%)
i_ret=CdiSetSnapMode(snapmode)
case CDI_3D_MODE
snapmode=CdiGet3DSnapMode()
i_ret=CdiSet3DSnapMode(CDI_NOSNAP)
i_ret=CdiSelect3DByPoint(l_osl,"Select object on layer to make active",CDI_OBJECT_SELECTION,CDI_FALSE,CDI_TRUE,pnt0,CDI_SEL3D_ALL)
if i_ret=CDI_ABORT then
i_ret=CdiFreeLocalOsl(l_osl&)
exit sub
end if

i_ret=CdiOslItem(l_osl&, 0, object1)
i_ret=CdiObjType(object1.sid,obj_type%,layer%)
i_ret=CdiSet3DSnapMode(snapmode)
end select

i_ret=CdiSetActLayer(layer)
i_ret=CdiFreeLocalOsl(l_osl&)
CdiStatusLineUpdate

end sub
Top of pagePrevious messageNext messageBottom of page Link to this message

Jeff_hayden (Jeff_hayden)
Username: Jeff_hayden

Registered: 09-2006
Posted on Monday, September 18, 2006 - 09:22 am:   

Thanks Ken. Unfortunately I wasn't smart enough to get it to work.
Top of pagePrevious messageNext messageBottom of page Link to this message

Ken_etter (Ken_etter)
Username: Ken_etter

Registered: 08-2006
Posted on Tuesday, September 12, 2006 - 03:41 am:   

Jeff,

Here is a snippet of code from a macro I have that prompts the user to select some text. The macro gets the layer the text is on. You can probably modify yours to work by looking at this.

i=CdiSelectbyPoint(l_osl,"Pick text closest to end desired - Button 2 to exit.",CDI_OBJECT_SELECTION,CDI_FALSE,CDI_TRUE,c2,CDI_SEL2D_TEXT)

'Retrieve text from OSL and assign its layer
i = CdiOslItem(l_osl, 0, object1)
i=CdiObjInfo(object1.sid, text_buff)
layer = text_buff.layer

If you need more help with it, let us know.

Ken
Top of pagePrevious messageNext messageBottom of page Link to this message

Jeff_hayden (Jeff_hayden)
Username: Jeff_hayden

Registered: 09-2006
Posted on Monday, September 11, 2006 - 02:09 pm:   

I've got this piece of code from a macro that I am working on. After the user selects the object for it to be queried, I want that object's layer to become the current active layer. I have tried the little piece of code after the SelectByPoint line below but no luck. I'm not a programmer but would love some advice from one. Thank you for any help.

prompt_1 = "Select object to calc it" + chr$(0)

i_ret = CdiMakeCursor (osl, CDI_RECT_CURSOR, ffp1, CDI_REL_CURSOR_MOVE, ffp2, CDI_REL_CURSOR_MOVE)
selection_mode = CDI_SEL2D_ALL

'set up OSL to receive text
dim ObjSid as long
dim ObjUniqueId as long
dim UniqueId as long
dim OslObject as CDI_OSL_OBJECT

i_ret =CdiSelectbyPoint(cv_osl,prompt_1,CDI_OBJECT_SELECTION,CDI_FALSE,CDI_TRUE,c1,sel ection_mode)

layer=CdiGetActLayer
layer=CdiObjGetLayer(seg_id)
i_ret=CdiSetActLayer(layer)

i_ret = cdiMenuEntry(IDM_QUERY_SIZE,CDI_BUTTON_2,CDI_NO_MENU_ITEM)

i_ret = cdiMenuEntry(IDM_DRAW_TEXT,CDI_BUTTON_2,CDI_NO_MENU_ITEM)

Add Your Message Here
Post:
Bold text Italics Underline Create a hyperlink Insert a clipart image

Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action:

Topics | Last Day | Last Week | Tree View | Search | Help/Instructions | Program Credits Administration