Started by velasquez ·
2009-05-25 23:31 UTC ·
6 replies · SMF topic #769
velasquez
2009-05-25 23:31 UTC
I close the MODAL form.
I ask for an insert point for a block.
I indicate a point in the screen.
The form is shown again.
The block appears in the screen.
The form should appear after the block.
Am I making some wrong thing?
(vla-insertBlock (JoyGetActiveSpace) ;_Pega o espaco ativo
(vlax-3d-point JoyInsPt)
"BlockName"
1 ;_xscalefactor
1 ;_ yscalefactor ent)
1 ;_ zscalefactor
0 ;_rotation)
fred_tomke
2009-05-26 05:46 UTC
Hi, velasquez, I don't know enough about your code but make sure that your form is showing within a loop.
(defun c:MyProj_MyForm_pb_Cancel_OnClicked ()
(dcl_form_close MyProj_MyForm 2)
); c:MyProj_MyForm_pb_Cancel_OnClicked
(defun c:MyProj_MyForm_pb_BlockInsert_OnClicked ()
(dcl_form_close MyProj_MyForm 3)
); c:MyProj_MyForm_pb_BlockInsert_OnClicked
(setq doCont T)
(while doCont
(setq doCont nil)
(setq intForm (dcl_form_show MyProj_MyForm))
(cond
((= intForm 2) (setq doCont nil)) ;; Cancelling the form via ESC or c:MyProj_MyForm_pb_Cancel_OnClicked
((= intForm 3)
(if (and (setq JoyInsPt (vl-catch-all-apply 'getpoint (list "\nPick a point to insert block: ")))
(not (vl-catch-all-error-p JoyInsPt)))
(setq oBlock (vla-insertBlock (JoyGetActiveSpace) ;_Pega o espaco ativo
(vlax-3d-point JoyInsPt)
"BlockName"
1 ;_xscalefactor
1 ;_ yscalefactor ent
1 ;_ zscalefactor
0 ;_rotation
))
))
); cond
); while
Fred
velasquez
2009-05-26 11:15 UTC
Hi Fred,
My form this working within the loop.
Your work seems better.
Don't I want to take your time but do you have an example working?
Does it can me to show?
Thank you very much.
Kerry Brown
2009-05-26 12:46 UTC
Hi, velasquez,
Have you had a look at the Selections.LSP and .ODCL in the samples folder.
Regards
Kerry
velasquez
2009-05-26 13:09 UTC
I posted my complete code.
I need to insert the block and to show the form again.
This should happen after the insert of the block and not before.
I don't know what am doing wrong.
Regards
Velasquez
fred_tomke
2009-05-26 15:10 UTC
Sorry, was my mistake, I've forgotten the line (setq doCont T) after inserting the block.
Please forgive me!
I've removed some comments to highlight the new comments
(defun c:Blki (/ intform oBlock strFileName strBlockName)
(dcl_Project_Load "MyProj")
(defun c:MyProj_MyForm_pb_Cancel_OnClicked ()
(dcl_form_close MyProj_MyForm 2)
); c:MyProj_MyForm_pb_Cancel_OnClicked
(defun c:MyProj_MyForm_pb_BlockInsert_OnClicked ()
(dcl_form_close MyProj_MyForm 3)
); c:MyProj_MyForm_pb_BlockInsert_OnClicked
(setq doCont T)
(setq strBlockName "BOLA") ;; whatever was selected
(while doCont
(setq doCont nil)
(setq intForm (dcl_form_show MyProj_MyForm))
(cond
((= intForm 2) (setq doCont nil)) ; Cancelling
((= intForm 3) ; Selecting
(if (and (or (tblsearch "Block" strBlockName)
(setq strFileName (findfile (strcat strBlockName ".dwg"))))
(setq JoyInsPt (vl-catch-all-apply 'getpoint (list "\nPick a point to insert block: ")))
(not (vl-catch-all-error-p JoyInsPt))
(setq oBlock (vl-catch-all-apply 'vla-insertBlock
(list (JoyGetActiveSpace) (vlax-3d-point JoyInsPt)
(if (tblsearch "Block" strBlockName) strBlockName strFileName)
1 1 1 0)))
(not (vl-catch-all-error-p oBlock)))
(vla-update (vlax-get-acad-object)) ;; otherwise you only see the new block after finishing the program
); if
(setq doCont T)) ; I've forgotten this line
); cond
); while
); Blki
Fred
velasquez
2009-05-26 16:36 UTC
Hi Fred,
I remembered after (setq doCont T).
But I didn't work with (vla-update (vlax-get-acad-object)).
Therefore I didn't see the block.
Your code worked very well now.
Thank you very much.
Vleasquez